Repository navigation
Performance Slowdown With One Additional Column #2359
Description
Activity
Table Schema:
{'column': 'ts', 'type': 'TIMESTAMP', 'indexed': False, 'indexBlockCapacity': 0, 'symbolCached': False, 'symbolCapacity': 0, 'designated': True} {'column': 'pair', 'type': 'SYMBOL', 'indexed': True, 'indexBlockCapacity': 0, 'symbolCached': True, 'symbolCapacity': 32, 'designated': False} {'column': 'exchange', 'type': 'SYMBOL', 'indexed': True, 'indexBlockCapacity': 0, 'symbolCached': True, 'symbolCapacity': 32, 'designated': False} {'column': 'open', 'type': 'DOUBLE', 'indexed': False, 'indexBlockCapacity': 0, 'symbolCached': False, 'symbolCapacity': 0, 'designated': False} {'column': 'high', 'type': 'DOUBLE', 'indexed': False, 'indexBlockCapacity': 0, 'symbolCached': False, 'symbolCapacity': 0, 'designated': False} {'column': 'low', 'type': 'DOUBLE', 'indexed': False, 'indexBlockCapacity': 0, 'symbolCached': False, 'symbolCapacity': 0, 'designated': False} {'column': 'close', 'type': 'DOUBLE', 'indexed': False, 'indexBlockCapacity': 0, 'symbolCached': False, 'symbolCapacity': 0, 'designated': False} {'column': 'volume', 'type': 'DOUBLE', 'indexed': False, 'indexBlockCapacity': 0, 'symbolCached': False, 'symbolCapacity': 0, 'designated': False}Row count: 62587165
Distinct pair: 190
Distinct exchange: 5hey Emmett, looking into it, bear with us. I got a hunch that you might want to drop those indexes on
pairandexchange. But let me validate this thesis first@bluestreak01 no worries– yes I have already dropped those indexes and it did decrease latency from 6000ms to ~1200ms. Just documenting here in case this is something you all want to look at
could you try these things (all of them):
- replace
inwith= - upgrade to 6.4.3, we fixed perf issue there fix(sql): improve performance of certain SAMPLE BY queries #2277
indoesn't use JIT (we will fix that),=does- replace
@EmmettM the date range is 6 months, how many rows would you get with this SQL:
select count() from 'ohlc_exchanges' where pair = 'btc-usd' and exchange = 'coinbase' and ts >= cast(1608864755 * 1000000L AS TIMESTAMP) and ts <= cast(1656125555 * 1000000L AS TIMESTAMP)
@bluestreak01 the result of that query is 157,847. Trying the other fixes now.
Just updated the rest of the code– I initially thought there were performance improvements, but my queries are actually taking longer now (18+ seconds). Just to recap:
QuestDB 6.4.3
Updated query:
select ts, last(close) from 'ohlc_exchanges_historical' where pair='btc-usd' and exchange='CPRO' and ts >= cast(0 * 1000000L AS TIMESTAMP) and ts <= cast(1656125555 * 1000000L AS TIMESTAMP) sample by 1d limit 5000
This query in particular took 18.689 seconds to return 1705 records. There must be something wrong.Schema (removed both indexes):
{'column': 'ts', 'type': 'TIMESTAMP', 'indexed': False, 'indexBlockCapacity': 0, 'symbolCached': False, 'symbolCapacity': 0, 'designated': True} {'column': 'pair', 'type': 'SYMBOL', 'indexed': False, 'indexBlockCapacity': 0, 'symbolCached': True, 'symbolCapacity': 256, 'designated': False} {'column': 'exchange', 'type': 'SYMBOL', 'indexed': False, 'indexBlockCapacity': 0, 'symbolCached': True, 'symbolCapacity': 256, 'designated': False} {'column': 'open', 'type': 'DOUBLE', 'indexed': False, 'indexBlockCapacity': 0, 'symbolCached': False, 'symbolCapacity': 0, 'designated': False} {'column': 'high', 'type': 'DOUBLE', 'indexed': False, 'indexBlockCapacity': 0, 'symbolCached': False, 'symbolCapacity': 0, 'designated': False} {'column': 'low', 'type': 'DOUBLE', 'indexed': False, 'indexBlockCapacity': 0, 'symbolCached': False, 'symbolCapacity': 0, 'designated': False} {'column': 'close', 'type': 'DOUBLE', 'indexed': False, 'indexBlockCapacity': 0, 'symbolCached': False, 'symbolCapacity': 0, 'designated': False} {'column': 'volume', 'type': 'DOUBLE', 'indexed': False, 'indexBlockCapacity': 0, 'symbolCached': False, 'symbolCapacity': 0, 'designated': False}This is a new table with 120,289,785 rows.
There are no error messages in the logs that would indicate that there is some kind of error.
Describe the bug
Getting an unexpectedly high latency on a relatively simple query:
select ts, last(close) from 'ohlc_exchanges' where pair in 'btc-usd' and exchange in 'coinbase' and ts >= cast(1608864755 * 1000000L AS TIMESTAMP) and ts <= cast(1656125555 * 1000000L AS TIMESTAMP) sample by 1d align to calendar with offset '00:00' limit 5000Table has ~65M rows. "Pair" and "exchange" are indexed and the table is partitioned by month. QDB 6.4.2. Query takes about 6000ms.
I have a similar table w/ ~25M rows that does not have the exchange column, and similar queries on this table take around 200ms.
To reproduce
No response
Expected Behavior
Expecting similar performance to the second table.
Environment
Additional context
No response