All Projects → postgrespro → sr_plan

postgrespro / sr_plan

Licence: other
Save and restore query plans in PostgreSQL

Programming Languages

c
50402 projects - #5 most used programming language
python
139335 projects - #7 most used programming language
PLpgSQL
1095 projects
shell
77523 projects
Makefile
30231 projects

Projects that are alternatives of or similar to sr plan

awesome-agi-cocosci
An awesome & curated list for Artificial General Intelligence, an emerging inter-discipline field that combines artificial intelligence and computational cognitive sciences.
Stars: ✭ 81 (+42.11%)
Mutual labels:  planning
planning-wiki
By the community, for everyone. Planning.wiki is the online guide to AI Planning
Stars: ✭ 54 (-5.26%)
Mutual labels:  planning
setting-up-an-open-source-project
🔁 Setting Up An Open Source Project
Stars: ✭ 14 (-75.44%)
Mutual labels:  planning
DnaWeaver
A route planner for DNA assembly
Stars: ✭ 20 (-64.91%)
Mutual labels:  planning
jpp
Joint Perception and Planning For Efficient Obstacle Avoidance Using Stereo Vision
Stars: ✭ 42 (-26.32%)
Mutual labels:  planning
nuplan-devkit
The devkit of the nuPlan dataset.
Stars: ✭ 107 (+87.72%)
Mutual labels:  planning
planner
Lightweight, interactive planning tool that visualizes a series of tasks using an HTML canvas
Stars: ✭ 502 (+780.7%)
Mutual labels:  planning
autonomous-delivery-robot
Repository for Autonomous Delivery Robot project of IvLabs, VNIT
Stars: ✭ 65 (+14.04%)
Mutual labels:  planning
l5kit
L5Kit - https://level-5.global/
Stars: ✭ 683 (+1098.25%)
Mutual labels:  planning
Annotated-Angular-Roadmap
More details about each item in the Angular roadmap (https://angular.io/guide/roadmap)
Stars: ✭ 41 (-28.07%)
Mutual labels:  planning
Robotics-Planning-Dynamics-and-Control
RPDC : This contains all my MATLAB codes for the Robotics, Planning, Dynamics and Control . The implementations model various kinds of manipulators and mobile robots for position control, trajectory planning and path planning problems.
Stars: ✭ 171 (+200%)
Mutual labels:  planning
mapus
A map tool with real-time collaboration 🗺️
Stars: ✭ 2,687 (+4614.04%)
Mutual labels:  planning
plasp
🗺️ ASP planning tools for PDDL
Stars: ✭ 24 (-57.89%)
Mutual labels:  planning
scrum-planning-poker
Please feel FREE to try it and give feedback by searching Scrum敏捷估算 in WeChat mini program.
Stars: ✭ 30 (-47.37%)
Mutual labels:  planning
Timetable-App
This is a timetable App for android phones.
Stars: ✭ 19 (-66.67%)
Mutual labels:  planning
urban-and-regional-planning-resources
Community list of data & technology resources concerning the built environment and communities. 🏙️🌳🚌🚦🗺️
Stars: ✭ 109 (+91.23%)
Mutual labels:  planning
GoPlan-app
An intuitive portfolio mangaer !
Stars: ✭ 27 (-52.63%)
Mutual labels:  planning
fun-with-dnc
Pytorch Implementation of Deepmind's 'Hybrid computing using a neural network with dynamic external memory' (Differentiable Neural Computer) + some applications
Stars: ✭ 18 (-68.42%)
Mutual labels:  planning
pm-discussify
Discussify's project management repository
Stars: ✭ 17 (-70.18%)
Mutual labels:  planning
taxi
Hierarchical Online Planning and Reinforcement Learning on Taxi
Stars: ✭ 24 (-57.89%)
Mutual labels:  planning

Build Status GitHub license

Save and restore query plans in PostgreSQL

Rationale

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.

Build and install

make USE_PGXS=1
make USE_PGXS=1 install

and modify your postgres config:

shared_preload_libraries = 'sr_plan'

Usage

Install the extension in your database:

CREATE EXTENSION sr_plan;

If you want to save the query plan is necessary to set the variable:

set sr_plan.write_mode = true;

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.

Make an example query:

select query_hash from sr_plans where query_hash=10;

Disable saving the plan for the query:

set sr_plan.write_mode = false;

Enable it:

update sr_plans set enable=true;

After that, the plan for the query will be taken from the sr_plans.

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. For the parameters we use a special function _p (anyelement) example:

select query_hash from sr_plans where query_hash=1000+_p(10);

If we keep the plan for the query and enable it to be used also for the following queries:

select query_hash from sr_plans where query_hash=1000+_p(11);
select query_hash from sr_plans where query_hash=1000+_p(-5);

EXPLAIN for saved plans

It is possible to see saved plans by using show_plan function. It requires knowing query hash which could be fetched from sr_plans table.

Examples:

Show enabled plan for query hash:

SELECT show_plan(1);
                  show_plan                   
----------------------------------------------
 ("Seq Scan on public.explain_test")
 ("  Output: test_attr1, test_attr2")
 ("  Filter: (explain_test.test_attr1 = 10)")
(3 rows)

Get second saved plan by using index parameter (ignores enable attribute):

SELECT show_plan(1, index := 2);
                  show_plan                   
----------------------------------------------
 ("Seq Scan on public.explain_test")
 ("  Output: test_attr1, test_attr2")
 ("  Filter: (explain_test.test_attr1 = 10)")
(3 rows)

Use another output format (supported formats are json, text, xml, yaml):

SELECT show_plan(1, format := 'json');
                      show_plan                       
------------------------------------------------------
 ("[                                                 +
   {                                                 +
     ""Plan"": {                                     +
       ""Node Type"": ""Seq Scan"",                  +
       ""Parallel Aware"": false,                    +
       ""Relation Name"": ""explain_test"",          +
       ""Schema"": ""public"",                       +
       ""Alias"": ""explain_test"",                  +
       ""Output"": [""test_attr1"", ""test_attr2""], +
       ""Filter"": ""(explain_test.test_attr1 = 10)""+
     }                                               +
   }                                                 +
 ]")
(1 row)

pg_stat_statements integration

sr_plans table contains query_id columns which could be used to make joins with pg_stat_statements tables and views.

Note: in shared_preload_libraries list pg_stat_statements should be specified after sr_plan.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].