You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
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.
5
+
sr_plan looks like Oracle Outline system. It can be used to lock
6
+
the execution plan. It is necessary if you do not trust the planner
7
+
or able to form a better plan.
8
+
9
+
Typically, DBA would play with queries interactively, and save their
10
+
plans and then enable use of saved plans for the queries, where
11
+
predictable responce time is essential.
12
+
13
+
Then application which uses these queries would use saved plans.
6
14
7
15
##Build
8
16
9
-
Dependencies: >= Python 3.2, Mako, pycparser
17
+
This module needs to serialize and deserialize lot of structures, which
18
+
results in almost same code.
19
+
20
+
So, mako preprocessor is used to generate C files serialize.c and
21
+
deserialize.c.
22
+
23
+
If you want to modify these files, you'll needed to alter mako templates
24
+
and regenerate files, so you'll need to install maco, python >= 3.2 and
25
+
pycparser modules.
26
+
10
27
If you only have a Python you can use the virtual environment:
11
28
```bash
12
29
virtualenv env
13
30
source ./env/bin/activate
14
31
pip install -r ./requirements.txt
15
32
```
16
33
17
-
Then you need to generate C code and compiled it:
34
+
Then you need to generate C code and compile it:
35
+
18
36
```bash
19
37
make USE_PGXS=1 genparser
20
38
make USE_PGXS=1
21
39
make USE_PGXS=1 install
22
40
```
23
41
24
-
and modify your postgres config:
25
-
```
26
-
shared_preload_libraries = 'sr_plan.so'
27
-
```
42
+
If you want to only build this module as is, pregenerated files are
43
+
provided for you, so``make genparser`` command should be omitted.
44
+
45
+
##Installation
28
46
29
-
##Usage
30
47
In your db:
31
48
```SQL
32
49
CREATE EXTENSION sr_plan;
33
50
```
51
+
and modify your postgresql.conf:
52
+
```
53
+
shared_preload_libraries = 'sr_plan.so'
54
+
```
55
+
It is essential that library is preloaded during server startup, because
56
+
use of saved plans is enabled on per-database basis and doesn't require
57
+
any per-connection actions.
58
+
59
+
##Usage
60
+
61
+
62
+
34
63
If you want to save the query plan is necessary to set the variable:
64
+
35
65
```SQL
36
66
setsr_plan.write_mode= true;
37
67
```
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.
68
+
69
+
Now plans for all subsequent queries will be stored in the table sr_plans,
70
+
until this variable is set to false. Don't forget that all queries will be
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:
97
+
Note use of explain\_jsonb\_plan function, that allows you to visualize
98
+
execution plan in the similar way as EXPLAIN command does.
99
+
100
+
In the database plans are stored as jsonb. By default, all the newly
101
+
saved plans are disabled, you need enable it manually: