Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit35d8331

Browse files
committed
Update README.md
1 parent20f3b16 commit35d8331

File tree

1 file changed

+52
-1
lines changed

1 file changed

+52
-1
lines changed

‎README.md

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,52 @@
1-
#sr_plan
1+
#Save and restore query plans in PostgreSQL
2+
3+
##Build
4+
5+
Dependencies: >= Python 3.2, Mako, pycparser
6+
If you only have a Python you can use the virtual environment:
7+
```bash
8+
virtualenv env
9+
source ./env/bin/activate
10+
pip install -r ./requirements.txt
11+
```
12+
13+
Then you need to generate C code and compiled it:
14+
```bash
15+
make USE_PGXS=1 genparser
16+
make USE_PGXS=1
17+
make USE_PGXS=1 install
18+
```
19+
20+
and modify your postgres config:
21+
```
22+
shared_preload_libraries = 'sr_plan.so'
23+
```
24+
25+
##Usage
26+
In your db:
27+
```SQL
28+
CREATE EXTENSION sr_plan;
29+
```
30+
If you want to save the query plan is necessary to set the variable:
31+
```SQL
32+
setsr_plan.write_mode= true;
33+
```
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.
35+
Making an example query:
36+
```SQL
37+
select query_hashfrom sr_planswhere query_hash=10;
38+
```
39+
disable saving the query:
40+
```SQL
41+
setsr_plan.write_mode= false;
42+
```
43+
Now verify that your query is saved:
44+
```SQL
45+
select query_hash, enable, query, explain_jsonb_plan(plan)from sr_plans;
46+
```
47+
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:
48+
```SQL
49+
update sr_plansset enable=truewhere query_hash=812619660;
50+
```
51+
(812619660 for example only)
52+
After that, the plan for the query will be taken from the sr_plans.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp