Skip to content

Commit aa296c2

Browse files
committed
fix docs
1 parent 062b032 commit aa296c2

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

README.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Save and restore query plans in PostgreSQL
22

3+
## Rationale
4+
5+
sr_plan looks like Oracle Outline system. It can be used to lock the execution plan. It is necessary if you do not trust the planner or able to form a better plan.
6+
37
## Build
48

59
Dependencies: >= Python 3.2, Mako, pycparser
@@ -31,7 +35,7 @@ If you want to save the query plan is necessary to set the variable:
3135
```SQL
3236
set sr_plan.write_mode = true;
3337
```
34-
Now plans for all subsequent requests will be stored in the table sr_plans. It must be remembered that all requests will be maintained including duplicates.
38+
Now plans for all subsequent queries will be stored in the table sr_plans. Don't forget that all queries will be stored including duplicates.
3539
Making an example query:
3640
```SQL
3741
select query_hash from sr_plans where query_hash=10;
@@ -43,12 +47,22 @@ set sr_plan.write_mode = false;
4347
Now verify that your query is saved:
4448
```SQL
4549
select query_hash, enable, valid, query, explain_jsonb_plan(plan) from sr_plans;
50+
51+
query_hash | enable | valid | query | explain_jsonb_plan
52+
------------+--------+-------+------------------------------------------------------+----------------------------------------------------
53+
1783086253 | f | t | select query_hash from sr_plans where query_hash=10; | Bitmap Heap Scan on sr_plans +
54+
| | | | Recheck Cond: (query_hash = 10) +
55+
| | | | -> Bitmap Index Scan on sr_plans_query_hash_idx+
56+
| | | | Index Cond: (query_hash = 10) +
57+
| | | |
58+
4659
```
60+
4761
explain_jsonb_plan function allows you to display explain execute the plan of which lies in jsonb. By default, all the plans are off, you need enable it:
4862
```SQL
49-
update sr_plans set enable=true where query_hash=812619660;
63+
update sr_plans set enable=true where query_hash=1783086253;
5064
```
51-
(812619660 for example only)
65+
(1783086253 for example only)
5266
After that, the plan for the query will be taken from the sr_plans.
5367

5468
In addition sr plan allows you to save a parameterized query plan. In this case, we have some constants in the query are not essential.

0 commit comments

Comments
 (0)