Skip to content

[Cache] One sql cache may exist many version #5792

@xinghuayu007

Description

@xinghuayu007

Cache Implement

Look at pic 1. Doris supports two kinds of cache: sql cache and partition cache. The cache structure is sql key -> {<partition key, cache data>, <partition key, cache data>, <partition key, cache data>}. One sql has one cache node, one cache node has many partition cache point. But for sql cache, it has only one partition cache point, partition key is the latest partition id. When fetch cache data, it will compare partition key and partition version, partition update time to make sure the cache data available.

Cache   ProcessOn免费在线作图,在线流程图,在线思维导图   (1)

The Problem

When a table has four partitons [p202103, p202104, p202105, p202106].

  1. partition p202103 is loaded data into it, it is the latest partition.
  2. select * from table will take the partition id of p202103 as the request param to fetche cache.
  3. sql cache will be planted, like <sql_key, {<p202103, cache data>}
  4. partition p202104 is loaded data into it, it is the latest partition.
  5. execute sql query select * from table, it will take the partition id of p202104 as the request param to fetche cache
  6. sql cache will be planted, like <sql_key, {<p202103, cache data>, <p202104, cache data>}

Therefore, in this situation, one sql key will exist many version cache, the old version can not be replaced by new cache. We expected one sql key has only one version cache in case of memory waste.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions