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
-- Show a query execution time made with AQO support for the planner
93
+
-- cardinality estimations. Here we return result of last execution.
94
+
RETURN QUERY
95
+
SELECT
96
+
row_number() OVER (ORDER BY (exectime, queryid, fs_hash) DESC) AS nn,
97
+
queryid, fs_hash, exectime, execs
98
+
FROM (
99
+
SELECT
100
+
aq.query_hashAS queryid,
101
+
aq.fspace_hashAS fs_hash,
102
+
execution_time_with_aqo[array_length(execution_time_with_aqo, 1)] AS exectime,
103
+
executions_with_aqo AS execs
104
+
FROMpublic.aqo_queries aq JOINpublic.aqo_query_stat aqs
105
+
ONaq.query_hash=aqs.query_hash
106
+
WHERE TRUE = ANY (SELECT unnest(execution_time_with_aqo) IS NOT NULL)
107
+
) AS q1
108
+
ORDER BY nn ASC;
109
+
110
+
ELSE
111
+
-- Show a query execution time made without any AQO advise.
112
+
-- Return an average value across all executions.
113
+
RETURN QUERY
114
+
SELECT
115
+
row_number() OVER (ORDER BY (exectime, queryid, fs_hash) DESC) AS nn,
116
+
queryid, fs_hash, exectime, execs
117
+
FROM (
118
+
SELECT
119
+
aq.query_hashAS queryid,
120
+
aq.fspace_hashAS fs_hash,
121
+
array_avg(execution_time_without_aqo) AS exectime,
122
+
executions_without_aqo AS execs
123
+
FROMpublic.aqo_queries aq JOINpublic.aqo_query_stat aqs
124
+
ONaq.query_hash=aqs.query_hash
125
+
WHERE TRUE = ANY (SELECT unnest(execution_time_without_aqo) IS NOT NULL)
126
+
) AS q1
127
+
ORDER BY (nn) ASC;
128
+
END IF;
129
+
END;
130
+
$$ LANGUAGE plpgsql;
131
+
132
+
COMMENT ON FUNCTION public.show_execution_time(boolean) IS
133
+
'Get execution time of queries. If controlled = true (AQO could advise cardinality estimations), show time of last execution attempt. Another case (AQO not used), return an average value of execution time across all known executions.';
Get execution time of queries. If controlled = true (AQO could advise cardinality estimations), show time of last execution attempt. Another case (AQO not used), return an average value of execution time across all known executions.
42
+
(1 row)
43
+
44
+
\df show_cardinality_errors
45
+
List of functions
46
+
Schema | Name | Result data type | Argument data types | Type
0 commit comments