Query planner: planner
planner uses statistics and saved plans to choose query plans. It requires
database, and saves plans in the database storage. Without planner, queries
use the built-in planner.
| Setting | Purpose | Default | Range |
|---|---|---|---|
queries | Maximum query identities tracked for learning. | 256 queries | 1–65,536 queries |
query-bytes | Memory reserved for query learning state. | 4 MiB | 64 KiB–1 GiB |
stored-plans | Maximum number of saved plans. | 1,024 plans | 0–1,048,576 plans |
stored-bytes | Maximum combined size of saved plan keys and values. | 1 MiB | 0–256 MiB |
Byte settings take integer counts of bytes in the configuration. Set
stored-plans or stored-bytes to zero to disable loading and saving plans.
Pending plan trials can use one third of query-bytes. With the default
4 MiB, 17 trials can wait at a time; at least one trial can always wait.
Dependencies
- Requires
database
Configuration
Select this plugin explicitly when opening the database:
| Offset (hex) | Bytes (hex) | Meaning |
|---|---|---|
| 00 | 54 52 4F 4E | magic TRON |
| 04 | 4C 70617468 | txt "path" |
| 09 | 6C 6170702E6462 | txt "app.db" |
| 10 | 0F 0A 04000000 0900 0000 | map leaf, size 10: @4 → @9 |
| 1A | BC 71756572792D62 79746573 | txt "query-bytes" |
| 26 | 02 00004000000000 00 | i64 4194304 |
| 2F | 0F 0A 1A000000 2600 0000 | map leaf, size 10: @1A → @26 |
| 39 | 7C 706C616E6E6572 | txt "planner" |
| 41 | 0F 0A 39000000 2F00 0000 | map leaf, size 10: @39 → @2F |
| 4B | 8C 64617461626173 65 | txt "database" |
| 54 | 0F 0A 4B000000 1000 0000 | map leaf, size 10: @4B → @10 |
| 5E | 07 0E 04100000 4100 0000 54000000 | map branch, size 14, depth 0 (root), slots 2, 12: @41 → @54 |
| 6C | 7C 706C7567696E73 | txt "plugins" |
| 74 | 0F 0A 6C000000 5E00 0000 | map leaf, size 10: @6C → @5E |
| 7E | 74000000 00000000 | root → @74; previous: none |
Usage
Select planner and database with a path when opening the database. Query execution can then use recorded statistics and saved plans. Use the explain request to inspect a query plan.