Skip to content

Commit a554674

Browse files
committed
fix(s3): add ::numeric casts for round() compatibility
total_exec_time/total_plan_time are double precision in pg_stat_statements. round(double precision, int) doesn't exist in PostgreSQL — need explicit ::numeric cast. Found by actually testing with shared_preload_libraries=pg_stat_statements.
1 parent bd227fe commit a554674

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

sql/s3_pg_stat_statements_workload.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ select
2424
coalesce(word, '???') as "Query Type",
2525
sum(calls) as "Calls",
2626
round(
27-
100.0 * sum(calls) / nullif(sum(sum(calls)) over (), 0), 1
27+
(100.0 * sum(calls) / nullif(sum(sum(calls)) over (), 0))::numeric, 1
2828
) as "Calls %",
2929
round(sum(total_exec_time)::numeric, 1) as "Exec (ms)",
3030
round(
31-
100.0 * sum(total_exec_time) / nullif(sum(sum(total_exec_time)) over (), 0), 1
31+
(100.0 * sum(total_exec_time) / nullif(sum(sum(total_exec_time)) over (), 0))::numeric, 1
3232
) as "Exec %",
3333
round(sum(total_plan_time)::numeric, 1) as "Plan (ms)",
3434
round(
@@ -57,11 +57,11 @@ select
5757
coalesce(word, '???') as "Query Type",
5858
sum(calls) as "Calls",
5959
round(
60-
100.0 * sum(calls) / nullif(sum(sum(calls)) over (), 0), 1
60+
(100.0 * sum(calls) / nullif(sum(sum(calls)) over (), 0))::numeric, 1
6161
) as "Calls %",
6262
round(sum(total_time)::numeric, 1) as "Time (ms)",
6363
round(
64-
100.0 * sum(total_time) / nullif(sum(sum(total_time)) over (), 0), 1
64+
(100.0 * sum(total_time) / nullif(sum(sum(total_time)) over (), 0))::numeric, 1
6565
) as "Time %",
6666
round(
6767
(sum(total_time) / nullif(sum(calls), 0))::numeric, 3

0 commit comments

Comments
 (0)