Skip to content

slow limit -N queries without order by ts queries  #2330

@bziobrowski

Description

@bziobrowski

Describe the bug

Looks like in latest release queries that use limit -N without explicit order by issued against tables with designated timestamp traverse partitions from first to last . This can make a big difference for tables with many partitions that get queried rarely enough to not be present in os cache .

To reproduce

create table test ( ts timestamp, d double, f float, i int, l long, s1 string, s2 string, sy symbol index) timestamp(ts) partition by day;

insert into test 
SELECT cast( (x*2500000)  as timestamp), x, x, cast(x as int), x, 's1' || (x%10), 's2' || (x%10), 'sy' || (x%10) 
from long_sequence(100000000);

selecT count(*) from test limit -5; 
--observe many 'open partition'  messages in logs

--after restart run
selecT * from test order by ts desc limit 5; 
--check that there's only 1 'open partition' message

Expected Behavior

No response

Environment

- **QuestDB version**:  6.4.4-snapshot
- **OS**: Windows
- **Browser**: Chrome

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIncorrect or unexpected behaviorSQLIssues or changes relating to SQL execution

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions