0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

SQLでORがあって時間がかかてるときに

Posted at

(都道府県=島根県 OR 都道府県=鳥取県)
で時間がかかっているとき、都道府県でINDEXかけてんのに、うまく使えてないときには

(都道府県=島根県)
UNION ALL
(都道府県=鳥取県)
のような連結で解決されるケースもある。

ORはANDのような絞り込みにならず難しい面がある

人間の事務作業で考えてみると分かりやすいかも。

実テーブルでいきなり2つをORで探すより
仮想テーブルAでは島根県を
仮想テーブルBでは鳥取県を
結果を後でマージする方が早かったりする。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?