questdb

Does QuestDB cache query results?


Are query results cached in QuestDB ? What does i.q.c.p.PGConnectionContext query cache used [fd=34248] appearing in logs mean ?

When I'm running

SELECT colX FROM (SUBQUERY)

for the first time it takes 1 second. On the next query it takes only 50 milliseconds.


Solution

  • QuestDB doesn't cache query results . Running a query is likely to fetch data from storage to OS page cache, warm up the data. On the second run it's possible that whole data set is in RAM and there's no need to wait on IO operations.

    To speed up query parsing, analysis and query plan building, QuestDB does cache execution plans.
    i.q.c.p.PGConnectionContext query cache used [fd=34248] means that compatible plan was found in pgwire cache and QuestDB can skip aforementioned query execution stages.

    You can adjust query cache sizes with the following server.conf settings :

    HTTP

    # enables the query cache
    #http.query.cache.enabled=true
    
    # sets the number of blocks for the query cache. Cache capacity is number_of_blocks * number_of_rows
    #http.query.cache.block.count=4
    
    # sets the number of rows for the query cache. Cache capacity is number_of_blocks * number_of_rows
    #http.query.cache.row.count=16
    

    PG wire protocol

    # enables select query cache
    #pg.select.cache.enabled=true
    
    # sets the number of blocks for the select query cache. Cache capacity is number_of_blocks * number_of_rows
    #pg.select.cache.block.count=16
    
    # sets the number of rows for the select query cache. Cache capacity is number_of_blocks * number_of_rows
    #pg.select.cache.row.count=16
    
    # enables insert query cache
    #pg.insert.cache.enabled=true
    
    # sets the number of blocks for the insert query cache. Cache capacity is number_of_blocks * number_of_rows
    #pg.insert.cache.block.count=8
    
    # sets the number of rows for the insert query cache. Cache capacity is number_of_blocks * number_of_rows
    #pg.insert.cache.row.count=8