Skip to content

Commit 49412f7

Browse files
committed
Introducing glossary term query planner, adding more details.
1 parent 0031fda commit 49412f7

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

src/content/docs/d1/best-practices/use-indexes.mdx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ sidebar:
66

77
---
88

9+
import { GlossaryTooltip } from "~/components";
10+
911
Indexes enable D1 to improve query performance over the indexed columns for common (popular) queries by reducing the amount of data (number of rows) the database has to scan when running a query.
1012

1113
## When is an index useful?
@@ -64,7 +66,11 @@ In more complex cases, you can confirm whether an index was used by D1 by [analy
6466

6567
### Run `PRAGMA optimize`
6668

67-
After creating an index, run the [`PRAGMA optimize`](/d1/sql-api/sql-statements/#pragma-optimize) command to improve your database performance.
69+
After creating an index, run the `PRAGMA optimize` command to improve your database performance.
70+
71+
`PRAGMA optimize` runs `ANALYZE` command on each table in the database, which collects statistics on the tables and indices. These statistics allows the <GlossaryTooltip term="query planner">query planner</GlossaryTooltip> to generate the most efficient query plan when executing the user query.
72+
73+
For more information, refer to [`PRAGMA optimize`](/d1/sql-api/sql-statements/#pragma-optimize).
6874

6975
## List indexes
7076

src/content/glossary/d1.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
productName: D1
3+
entries:
4+
- term: "query planner"
5+
general_definition: |-
6+
A component in a database management system which takes a user query and generates the most efficient plan of executing that query (the query plan). For example, the query planner decides which indices to use, or which table to access first.

src/content/partials/d1/use-pragma-statements.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{}
33
---
44

5-
import { Details } from "~/components";
5+
import { Details, GlossaryTooltip } from "~/components";
66

77
The PRAGMA statement examples on this page use the following SQL.
88

@@ -414,7 +414,7 @@ Refer to the [foreign key documentation](/d1/sql-api/foreign-keys/) to learn mor
414414

415415
### `PRAGMA optimize`
416416

417-
Attempts to optimize all schemas in a database by running the `ANALYZE` command for each table, if necessary. `ANALYZE` updates an internal table which contain statistics about tables and indices. These statistics helps the query planner to execute the input query more efficiently.
417+
Attempts to optimize all schemas in a database by running the `ANALYZE` command for each table, if necessary. `ANALYZE` updates an internal table which contain statistics about tables and indices. These statistics helps the <GlossaryTooltip term="query planner">query planner</GlossaryTooltip> to execute the input query more efficiently.
418418

419419
When `PRAGMA optimize` runs `ANALYZE`, it sets a limit to ensure the command does not take too long to execute. Alternatively, `PRAGMA optimize` may deem it unnecessary to run `ANALYZE` (for example, if the schema has not changed significantly). In this scenario, no optimizations are made.
420420

0 commit comments

Comments
 (0)