Skip to content

Instantly share code, notes, and snippets.

@doryokujin
Last active July 3, 2017 06:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doryokujin/98801ea5322b105cf77bea504e1c1a7d to your computer and use it in GitHub Desktop.
Save doryokujin/98801ea5322b105cf77bea504e1c1a7d to your computer and use it in GitHub Desktop.
-- 元のクエリ
col1 < 100 OR col2 is TRUE AND TD_TIME_RANGE(time, '2015-11-01')
-- 上のクエリは AND が優先的に考慮されるため, 以下のクエリと同義になります。
-- OR によって左右に分解されたこのクエリでは, TD_TIME_RANGE があるにも関わらず, (col1 < 100) の判定のために全件スキャンになります!
(col1 < 100) OR (col2 is TRUE AND TD_TIME_RANGE(time, '2015-11-01')) 
-- クエリ全体に TIME_RANGE 制約を利かす場合は明示的に () を使いましょう!
-- 以下のクエリでは TIME_RANGE 制約内のデータセットで (col1 < 100 OR col2 is TRUE) が判定されます。
(col1 < 100 OR col2 is TRUE) AND TD_TIME_RANGE(time, '2015-11-01')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment