YugabyteDB Query Planning And Caching Behavior
YugabyteDB's query planner switches between custom & generic plans based on executions (5 by default) & estimated cost. `plan_cache_mode` can be set to "auto" for automatic switching.
Here is a small test case to demonstrate plan_cache_mode, a PostgreSQL 12 feature available in YugabyteDB 2.25
yugabyte=> \c
psql (16.2, server 15.2-YB-2.25.0.0-b0)
You are now connected to database "yugabyte" as user "yugabyte".
yugabyte=> drop table if exists t;
DROP TABLE
yugabyte=> deallocate all;
show plan_cache_mode;
DEALLOCATE ALL
yugabyte=> show plan_cache_mode;
plan_cache_mode
-----------------
auto
(1 row)
I create a small table and a prepared query:
yugabyte=>...