4.1. AQO (Adaptive Query Optimization) #
AQO is a Shardman extension that uses query execution statistics for improving cardinality estimation, which can optimize execution plans and, consequently, speed up query execution.
To turn on AQO:
Add
aqoto theshared_preload_librariesparameter in sdmspec.json.Create extension
aqoon all nodes.SET shardman.broadcast_ddl TO ON; CREATE EXTENSION aqo; RESET shardman.broadcast_ddl;
Set
aqo.modeforlearnand run queries that you want to optimize withEXPLAIN ANALYZEuntil the plan stops changing.BEGIN; SET aqo.mode = 'learn'; EXPLAIN ANALYZE <query> RESET aqo.mode; COMMIT;
Note that aqo statistics is collected separately on all nodes in a Shardman cluster. So you need to repeat this process on each node in the cluster. Alternatively, you can set
aqo.modetolearnand run your application for some time and later turn it back to the default mode (controlled).
Note
AQO will not be activated if you join less than aqo.join_threshold relations (3 by default).
Complete aqo documentation can be found here.