Advertisement
TDCustmerSupportJP

Untitled

Jul 3rd, 2017
8,334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.74 KB | None | 0 0
  1. -- 元のクエリ
  2.  col1 < 100  OR col2 is TRUE  AND TD_TIME_RANGE(time, '2015-11-01')
  3.  
  4. -- 上のクエリは AND が優先的に考慮されるため, 以下のクエリと同義になります。
  5. -- OR によって左右に分解されたこのクエリでは, TD_TIME_RANGE があるにも関わらず, (col1 < 100) の判定のために全件スキャンになります!
  6.  (col1 < 100) OR (col2 is TRUE AND TD_TIME_RANGE(time, '2015-11-01')) 
  7.  
  8. -- クエリ全体に TIME_RANGE 制約を利かす場合は明示的に () を使いましょう!
  9. -- 以下のクエリでは TIME_RANGE 制約内のデータセットで (col1 < 100 OR col2 is TRUE) が判定されます。
  10.  (col1 < 100 OR col2 is TRUE) AND TD_TIME_RANGE(time, '2015-11-01')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement