https://questdb.io logo
Title
a

Andy Beyer

03/21/2023, 12:08 PM
I have a question about
ORDER BY
in queries: My tables have
timestamp
as the designated timestamp column If I run this query:
select * from '<my-table>' where _timestamp_ > '2023-01-01T00:00:00Z' order by _timestamp_ desc;
I get
4214
results despite the fact that data is being regularly added to the table When I add a
LIMIT
clause to a
desc
sorted query:
select * from '<my-table>' where _timestamp_ > '2023-01-01T00:00:00Z' order by _timestamp_ desc limit 100000;
then I get 0 results If I do either of the above with
order by timestamp asc
I get the full results I am expected (~750000 results with no limit, or the full 100,000 results with the limit) Is there something special about sorting using time in descending order?
j

Jaromir Hamala

03/21/2023, 2:25 PM
hi, that smells like a bug. what questdb version is it?
a

Andy Beyer

03/21/2023, 2:25 PM
7.0.1
j

Jaromir Hamala

03/21/2023, 2:26 PM
ok, that’s not good. please open an issue at https://github.com/questdb/questdb/issues/new?assignees=&amp;labels=bug&amp;template=bug_report.yaml ideally with a reproducer. thanks a lot!
a

Andy Beyer

03/21/2023, 2:27 PM
OK thanks, I'll try and write a self-contained example program
j

Jaromir Hamala

03/21/2023, 2:27 PM
can you please also paste results of the same queries, but prefixed with
explain
? so
explain select * from ….
?
a

Andy Beyer

03/21/2023, 2:28 PM
will do on my next run of my system test which I should perform in the next ~1 hour... will update once I get that data
j

Jaromir Hamala

03/21/2023, 2:28 PM
cool, many thanks!
a

Andy Beyer

03/21/2023, 2:28 PM
np, ty
we can work from here, working on a repro: https://github.com/questdb/questdb/issues/3081
it doesn't quite behave the same way as my real system test (for the real system test, the unlimited desc query will just have the incorrect number of rows) but the limited desc query usually return 0, and sometimes crashes the server (logs attached to the ticket)
filed another similar issue with another repro: https://github.com/questdb/questdb/issues/3163