Skip to content

Commit

Permalink
Add new view plan_history_pretty to improve readability
Browse files Browse the repository at this point in the history
  • Loading branch information
yamatattsu committed Jul 30, 2024
1 parent 6b41a96 commit bba1f8e
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions pg_plan_advsr--0.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ CREATE TABLE plan_repo.plan_history
join_hint text,
lead_hint text,
diff_of_scans double precision,
max_diff_ratio_scan double precision,
max_diff_ratio_scan double precision,
diff_of_joins double precision,
max_diff_ratio_join double precision,
max_diff_ratio_join double precision,
join_cnt int,
application_name text,
timestamp timestamp
Expand All @@ -41,6 +41,27 @@ CREATE TABLE plan_repo.raw_queries
timestamp timestamp
);

-- Register view
CREATE VIEW plan_repo.plan_history_pretty
AS
SELECT id,
norm_query_hash,
pgsp_queryid,
pgsp_planid,
execution_time::numeric(18, 3),
rows_hint,
scan_hint,
join_hint,
lead_hint,
diff_of_scans,
max_diff_ratio_scan::numeric(18, 2),
diff_of_joins,
max_diff_ratio_join::numeric(18, 2),
join_cnt,
application_name,
timestamp
FROM plan_repo.plan_history
ORDER BY id;

-- Register functions
CREATE FUNCTION pg_plan_advsr_enable_feedback()
Expand Down Expand Up @@ -68,3 +89,9 @@ RETURNS text
LANGUAGE SQL
IMMUTABLE
RETURNS NULL ON NULL INPUT;

-- Grant
GRANT SELECT ON plan_repo.plan_history TO PUBLIC;
GRANT SELECT ON plan_repo.norm_queries TO PUBLIC;
GRANT SELECT ON plan_repo.raw_queries TO PUBLIC;
GRANT USAGE ON SCHEMA plan_repo TO PUBLIC

0 comments on commit bba1f8e

Please sign in to comment.