You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Query plan in web ui shows the intervals are fully scanned when there's
a BETWEEN clause on DATE_TRUNC('DAY, __time)`
a NOT IN clause containing a list of dates with some adjacent days that are inside the between interval
some other filter on some other column
in the query.
Affected Versi
29.0.1
Description
I believe there's some problem/bug with the query planner.
For example, here's a query that works in my setup (it's a small cluster of several servers):
SELECT*FROM mytable
WHERE __time BETWEEN '2024-03-01'and'2024-03-10'and mycol ='ABC'and DATE_TRUNC('day', __time) not in (TIMESTAMP'2024-03-05', '2024-03-07')
(I changed the names of columns/tables except for __time)
By "works" I mean it works fast and the intervals are optimal in the plan:
But once I change the dates list in the not in part to have two adjacent dates:
SELECT*FROM mytable
WHERE __time BETWEEN '2024-03-01'and'2024-03-10'and mycol ='ABC'and DATE_TRUNC('day', __time) not in (TIMESTAMP'2024-03-05', '2024-03-06')
intervals get a full scan (and the query hangs forever):
Another interesting case is when I take the problematic query and delete the additional filter by another column (note the commented out and mycol = 'ABC' in this one):
SELECT*FROM mytable
WHERE __time BETWEEN '2024-03-01'and'2024-03-10'--and symbol = 'SPY'and DATE_TRUNC('day', __time) not in (TIMESTAMP'2024-03-05', '2024-03-06')
This time the intervals are just as expected and the query is fast again:
Query plan in web ui shows the intervals are fully scanned when there's
BETWEEN
clause onDATE_TRUNC('DAY
, __time)`NOT IN
clause containing a list of dates with some adjacent days that are inside thebetween
intervalin the query.
Affected Versi
29.0.1
Description
I believe there's some problem/bug with the query planner.
For example, here's a query that works in my setup (it's a small cluster of several servers):
(I changed the names of columns/tables except for
__time
)By "works" I mean it works fast and the intervals are optimal in the plan:
But once I change the dates list in the
not in
part to have two adjacent dates:intervals get a full scan (and the query hangs forever):
Another interesting case is when I take the problematic query and delete the additional filter by another column (note the commented out
and mycol = 'ABC'
in this one):This time the intervals are just as expected and the query is fast again:
Anyways, I expected the query planner/optimizer should always understand the constraints set by the dates in my
between
clause in all cases.Let me know if you want any other info, I'll try to provide whatever I can.
The text was updated successfully, but these errors were encountered: