About the timing of executing repetitive query statements

Comments

1 comment

  • Avatar
    Candido Dessanti

    HI HelloK,

    HeavyDB didn't cache the results, except you explicitly ask to do via a query hint, but the first time you run a query some structures are cached. This is a brief list:

    1. The optimized plan of the query and the associated LLVM is cached, and can be used for the next execution, even if you change the value you filter in a query (just like other databases like Oracle).
    2. The data of the columns needed by the query is cached in the CPU and (if present) GPU memory, and also this can be reused in the next execution of the query.
    3. If a join occur, a hash-table is generated for the outer table, and also this is cached, so assuming that data isn't changed in subsequent queries, can be recycled for a faster execution.

    If you the result of your query cached, you need to add the hint keep_result in your select statement in this form

    SELECT /*+ keep_result */ ...
    FROM your_table

    WHERE ...
    GROUP BY ...

    So each subsequent run will return immediatly the cached result without use any resource of the system.

    We had a discussion about this in github.

    About the timing of executing repetitive query statements

    Regards,
    Candido

     

    0
    Comment actions Permalink

Please sign in to leave a comment.