Uh oh!
There was an error while loading. Please reload this page.
[enhancement](Nereids) Enable parse sql from sql cache - #33262
Merged
Conversation
doris-robot
commented
Apr 4, 2024
Thank you for your contribution to Apache Doris. Since 2024-03-18, the Document has been moved to doris-website. |
924060929
commented
Apr 4, 2024
ContributorAuthor
run buildall |
doris-robot
commented
Apr 4, 2024
TPC-H: Total hot run time: 38368 ms |
doris-robot
commented
Apr 4, 2024
TPC-DS: Total hot run time: 182044 ms |
doris-robot
commented
Apr 4, 2024
ClickBench: Total hot run time: 30.75 s |
doris-robot
commented
Apr 4, 2024
Load test result on machine: 'aliyun_ecs.c7a.8xlarge_32C64G' |
924060929
commented
Apr 5, 2024
ContributorAuthor
run buildall |
doris-robot
commented
Apr 5, 2024
TPC-H: Total hot run time: 38365 ms |
doris-robot
commented
Apr 5, 2024
TPC-DS: Total hot run time: 181646 ms |
doris-robot
commented
Apr 5, 2024
ClickBench: Total hot run time: 29.56 s |
doris-robot
commented
Apr 5, 2024
Load test result on machine: 'aliyun_ecs.c7a.8xlarge_32C64G' |
924060929
commented
Apr 7, 2024
ContributorAuthor
run buildall |
1 similar comment
924060929
commented
Apr 7, 2024
ContributorAuthor
run buildall |
doris-robot
commented
Apr 7, 2024
TPC-H: Total hot run time: 38298 ms |
doris-robot
commented
Apr 7, 2024
TPC-DS: Total hot run time: 181634 ms |
doris-robot
commented
Apr 7, 2024
ClickBench: Total hot run time: 29.72 s |
doris-robot
commented
Apr 7, 2024
Load test result on machine: 'aliyun_ecs.c7a.8xlarge_32C64G' |
924060929
commented
Apr 7, 2024
ContributorAuthor
run buildall |
1 similar comment
924060929
commented
Apr 7, 2024
ContributorAuthor
run buildall |
doris-robot
commented
Apr 7, 2024
TPC-H: Total hot run time: 38087 ms |
doris-robot
commented
Apr 7, 2024
TPC-DS: Total hot run time: 180834 ms |
doris-robot
commented
Apr 7, 2024
ClickBench: Total hot run time: 30.22 s |
doris-robot
commented
Apr 7, 2024
Load test result on machine: 'aliyun_ecs.c7a.8xlarge_32C64G' |
924060929
commented
Apr 7, 2024
ContributorAuthor
run buildall |
Contributor
clang-tidy review says "All clean, LGTM! 👍" |
924060929
commented
Apr 7, 2024
ContributorAuthor
run buildall |
Merged
16 tasks
924060929 added a commit
to 924060929/incubator-doris
that referenced
this pull request
Nov 30, 2024
…yy-MM-dd HH:mm:ss') (apache#44631) fix sql cache result wrong of from_unixtime(col, 'yyyy-MM-dd HH:mm:ss') which introduced by apache#33262 the wrong result: is `yyyy-MM-dd HH:mm:ss` (cherry picked from commit d592e27)
924060929 added a commit
to 924060929/incubator-doris
that referenced
this pull request
Nov 30, 2024
…yy-MM-dd HH:mm:ss') (apache#44631) fix sql cache result wrong of from_unixtime(col, 'yyyy-MM-dd HH:mm:ss') which introduced by apache#33262 the wrong result: is `yyyy-MM-dd HH:mm:ss` (cherry picked from commit d592e27)
3 tasks
16 tasks
924060929 added a commit
that referenced
this pull request
Jan 7, 2025
1. use retry to fix unstable test `colocate_union_numbers`, `prune_bucket_with_bucket_shuffle_join` 2. fix failed test `explain`, this bug only exists in master branch, introduced by #40202 3. fix sql cache bug which use stale cache after drop table and create(table id changed), test in `parse_sql_from_sql_cache`, introduced by #33262 4. regression test add `foreachFrontends`, `foreachBackends`, `retry` function
924060929 added a commit
to 924060929/incubator-doris
that referenced
this pull request
Jan 7, 2025
1. use retry to fix unstable test `colocate_union_numbers`, `prune_bucket_with_bucket_shuffle_join` 2. fix failed test `explain`, this bug only exists in master branch, introduced by apache#40202 3. fix sql cache bug which use stale cache after drop table and create(table id changed), test in `parse_sql_from_sql_cache`, introduced by apache#33262 4. regression test add `foreachFrontends`, `foreachBackends`, `retry` function (cherry picked from commit e718c0b)
github-actionsBot
pushed a commit
that referenced
this pull request
Jan 7, 2025
1. use retry to fix unstable test `colocate_union_numbers`, `prune_bucket_with_bucket_shuffle_join` 2. fix failed test `explain`, this bug only exists in master branch, introduced by #40202 3. fix sql cache bug which use stale cache after drop table and create(table id changed), test in `parse_sql_from_sql_cache`, introduced by #33262 4. regression test add `foreachFrontends`, `foreachBackends`, `retry` function
924060929 pushed a commit
that referenced
this pull request
Jan 7, 2025
…46506) 1. use retry to fix unstable test `colocate_union_numbers`, `prune_bucket_with_bucket_shuffle_join` 2. fix sql cache bug which use stale cache after drop table and create(table id changed), test in `parse_sql_from_sql_cache`, introduced by #33262 3. regression test add `foreachFrontends`, `foreachBackends`, `retry` function
yiguolei pushed a commit
to 924060929/incubator-doris
that referenced
this pull request
Jan 8, 2025
1. use retry to fix unstable test `colocate_union_numbers`, `prune_bucket_with_bucket_shuffle_join` 2. fix failed test `explain`, this bug only exists in master branch, introduced by apache#40202 3. fix sql cache bug which use stale cache after drop table and create(table id changed), test in `parse_sql_from_sql_cache`, introduced by apache#33262 4. regression test add `foreachFrontends`, `foreachBackends`, `retry` function (cherry picked from commit e718c0b)
16 tasks
924060929 added a commit
that referenced
this pull request
Mar 12, 2025
…erException (#48902) fix prepare statement with sql cache throw NullPointerException, introduced by #33262. forbid sql cache when useServerPrepStmts=true, the mysql protocol has different between COM_QUERY and COM_STMT_EXECUTE, the sql cache use the result of COM_QUERY, so we can not provide the result of sql cache for COM_STMT_EXECUTE
924060929 added a commit
to 924060929/incubator-doris
that referenced
this pull request
Mar 12, 2025
…erException (apache#48902) fix prepare statement with sql cache throw NullPointerException, introduced by apache#33262. forbid sql cache when useServerPrepStmts=true, the mysql protocol has different between COM_QUERY and COM_STMT_EXECUTE, the sql cache use the result of COM_QUERY, so we can not provide the result of sql cache for COM_STMT_EXECUTE (cherry picked from commit 74ad0e3)
924060929 added a commit
to 924060929/incubator-doris
that referenced
this pull request
Mar 12, 2025
…erException (apache#48902) fix prepare statement with sql cache throw NullPointerException, introduced by apache#33262. forbid sql cache when useServerPrepStmts=true, the mysql protocol has different between COM_QUERY and COM_STMT_EXECUTE, the sql cache use the result of COM_QUERY, so we can not provide the result of sql cache for COM_STMT_EXECUTE (cherry picked from commit 74ad0e3)
koarz pushed a commit
to koarz/doris
that referenced
this pull request
Jun 4, 2025
…erException (apache#48902) fix prepare statement with sql cache throw NullPointerException, introduced by apache#33262. forbid sql cache when useServerPrepStmts=true, the mysql protocol has different between COM_QUERY and COM_STMT_EXECUTE, the sql cache use the result of COM_QUERY, so we can not provide the result of sql cache for COM_STMT_EXECUTE
GoGoWen pushed a commit
to GoGoWen/incubator-doris
that referenced
this pull request
Sep 26, 2025
…che=true (apache#42032) (apache#42034) fix `Is Cached` is not Yes in Profile when enable_sql_cache=true, introduced by apache#33262
zhangm365
commented
Oct 24, 2025
Contributor
hello, how to invalidate cache? |
HappenLee pushed a commit
to HappenLee/incubator-doris
that referenced
this pull request
Apr 24, 2026
Before this pr, the query must pass through parser, analyzer, rewriter, optimizer and translator, then we can check whether this query can use sql cache, if the query is too long, or the number of join tables too big, the plan time usually >= 500ms. This pr reduce this time by skip the fashion plan path, because we can reuse the previous physical plan and query result if no any changed. In some cases we should not parse sql from sql cache, e.g. table structure changed, data changed, user policies changed, privileges changed, contains non-deterministic functions, and user variables changed. In my test case: query a view which has lots of join and union, and the tables has empty partition, the query latency is about 3ms. if not parse sql from sql cache, the plan time is about 550ms ## Features 1. use Config.sql_cache_manage_num to control how many sql cache be reused in on fe 2. if explain plan appear some plans contains `LogicalSqlCache` or `PhysicalSqlCache`, it means the query can use sql cache, like this: ```sql mysql> set enable_sql_cache=true; Query OK, 0 rows affected (0.00 sec) mysql> explain physical plan select * from test.t; +----------------------------------------------------------------------------------+ | Explain String(Nereids Planner) | +----------------------------------------------------------------------------------+ | cost = 3.135 | | PhysicalResultSink[53] ( outputExprs=[c1#0, c2#1] ) | | +--PhysicalDistribute[50]@0 ( stats=3, distributionSpec=DistributionSpecGather ) | | +--PhysicalOlapScan[t]@0 ( stats=3 ) | +----------------------------------------------------------------------------------+ 4 rows in set (0.02 sec) mysql> select * from test.t; +------+------+ | c1 | c2 | +------+------+ | 1 | 2 | | -2 | -2 | | NULL | 30 | +------+------+ 3 rows in set (0.05 sec) mysql> explain physical plan select * from test.t; +-------------------------------------------------------------------------------------------+ | Explain String(Nereids Planner) | +-------------------------------------------------------------------------------------------+ | cost = 0.0 | | PhysicalSqlCache[2] ( queryId=78511f515cda466b-95385d892d6c68d0, backend=127.0.0.1:9050 ) | | +--PhysicalResultSink[52] ( outputExprs=[c1#0, c2#1] ) | | +--PhysicalDistribute[49]@0 ( stats=3, distributionSpec=DistributionSpecGather ) | | +--PhysicalOlapScan[t]@0 ( stats=3 ) | +-------------------------------------------------------------------------------------------+ 5 rows in set (0.01 sec) ```
HappenLee pushed a commit
to HappenLee/incubator-doris
that referenced
this pull request
Apr 24, 2026
…ontends (apache#33722) fix some sql cache consistence bug between multiple frontends which introduced by [enhancement](Nereids) Enable parse sql from sql cache apache#33262, fix by use row policy as the part of sql cache key. support dynamic update the num of fe manage sql cache key
HappenLee pushed a commit
to HappenLee/incubator-doris
that referenced
this pull request
Apr 24, 2026
…cache=true (apache#42032) fix `Is Cached` is not Yes in Profile when enable_sql_cache=true, introduced by apache#33262
HappenLee pushed a commit
to HappenLee/incubator-doris
that referenced
this pull request
Apr 24, 2026
…yy-MM-dd HH:mm:ss') (apache#44631) fix sql cache result wrong of from_unixtime(col, 'yyyy-MM-dd HH:mm:ss') which introduced by apache#33262 the wrong result: is `yyyy-MM-dd HH:mm:ss`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
Before this pr, the query must pass through parser, analyzer, rewriter, optimizer and translator, then we can check whether this query can use sql cache, if the query is too long, or the number of join tables too big, the plan time usually >= 500ms.
This pr reduce this time by skip the fashion plan path, because we can reuse the previous physical plan and query result if no any changed. In some cases we should not parse sql from sql cache, e.g. table structure changed, data changed, user policies changed, privileges changed, contains non-deterministic functions, and user variables changed.
In my test case: query a view which has lots of join and union, and the tables has empty partition, the query latency is about 3ms. if not parse sql from sql cache, the plan time is about 550ms
Features
LogicalSqlCacheorPhysicalSqlCache, it means the query can use sql cache, like this: