https://questdb.io logo
Title
f

Fritz

01/18/2023, 4:07 PM
Hi, I'm Fritz and we are evaluating QuestDB for our high-resolution time series data storage. One think I came across today is a similar issue as this: https://github.com/questdb/questdb/issues/2285 I see that the issue with LIMIT seems to be fixed (https://github.com/questdb/questdb/pull/2572) (and at least in 6.6.1 it works (did not work in 6.5.5)). But: I cannot use ORDER BY when sampling and also together with LIMIT E.g. I want to do the following query:
SELECT device, ts, avg(measured_val) 
FROM sensor_data where ts > '2022-03-18' 
SAMPLE BY 1m ALIGN TO CALENDAR 
ORDER BY ts DESC 
LIMIT 10;
The intention is to get the latest 10 average 15minute interval reads from our sensors. The error message I get is:
"base query does not provide ASC order over dedicated TIMESTAMP column"
(Which I don't understand). Without the ORDER BY ts DESC the query works but I get it in ascending order, eg. 00:00, 00:15, 00:30, etc. But I'd like to retrieve it like 16:00, 15:45, 15:30, etc. (if 16:00 is the most recent entry). Am I doing it wrong? Do I need to encapsulate the query into a subquery and run an outer query just to sort? Or will this feature be added in a later release? Thanks!
b

Bolek Ziobrowski

01/18/2023, 4:36 PM
Hi Fritz. This query seems to run fine in latest master branch (assuming ts is a designated timestamp) .
n

Nicolas Hourcard

01/18/2023, 5:06 PM
Hi Fritz, welcome to our community! Would you be able to share a little bit more about the use case? thanks a ton!