-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
270 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,56 @@ | ||
version: '3' | ||
|
||
services: | ||
postgres11: | ||
image: postgres:11.18-alpine | ||
postgres12: | ||
image: postgres:12.20-alpine | ||
command: postgres -c shared_preload_libraries=pg_stat_statements | ||
environment: | ||
POSTGRES_USER: postgres | ||
POSTGRES_DB: ecto_psql_extras_test | ||
POSTGRES_PASSWORD: postgres | ||
POSTGRES_DB: ecto-psql-extras-test | ||
POSTGRES_PASSWORD: secret | ||
ports: | ||
- '5432:5432' | ||
postgres12: | ||
image: postgres:12.13-alpine | ||
postgres13: | ||
image: postgres:13.16-alpine | ||
command: postgres -c shared_preload_libraries=pg_stat_statements | ||
environment: | ||
POSTGRES_USER: postgres | ||
POSTGRES_DB: ecto_psql_extras_test | ||
POSTGRES_PASSWORD: postgres | ||
POSTGRES_DB: ecto-psql-extras-test | ||
POSTGRES_PASSWORD: secret | ||
ports: | ||
- '5433:5432' | ||
postgres13: | ||
image: postgres:13.3-alpine | ||
postgres14: | ||
image: postgres:14.13-alpine | ||
command: postgres -c shared_preload_libraries=pg_stat_statements | ||
environment: | ||
POSTGRES_USER: postgres | ||
POSTGRES_DB: ecto_psql_extras_test | ||
POSTGRES_PASSWORD: postgres | ||
POSTGRES_DB: ecto-psql-extras-test | ||
POSTGRES_PASSWORD: secret | ||
ports: | ||
- '5434:5432' | ||
postgres14: | ||
image: postgres:14.6-alpine | ||
postgres15: | ||
image: postgres:15.8-alpine | ||
command: postgres -c shared_preload_libraries=pg_stat_statements | ||
environment: | ||
POSTGRES_USER: postgres | ||
POSTGRES_DB: ecto_psql_extras_test | ||
POSTGRES_PASSWORD: postgres | ||
POSTGRES_DB: ecto-psql-extras-test | ||
POSTGRES_PASSWORD: secret | ||
ports: | ||
- '5435:5432' | ||
postgres15: | ||
image: postgres:15.1-alpine | ||
postgres16: | ||
image: postgres:16.4-alpine | ||
command: postgres -c shared_preload_libraries=pg_stat_statements | ||
environment: | ||
POSTGRES_USER: postgres | ||
POSTGRES_DB: ecto_psql_extras_test | ||
POSTGRES_PASSWORD: postgres | ||
POSTGRES_DB: ecto-psql-extras-test | ||
POSTGRES_PASSWORD: secret | ||
ports: | ||
- '5436:5432' | ||
postgres17: | ||
image: postgres:17.0-alpine | ||
command: postgres -c shared_preload_libraries=pg_stat_statements | ||
environment: | ||
POSTGRES_USER: postgres | ||
POSTGRES_DB: ecto-psql-extras-test | ||
POSTGRES_PASSWORD: secret | ||
ports: | ||
- '5437:5432' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
defmodule EctoPSQLExtras.Calls17 do | ||
@behaviour EctoPSQLExtras | ||
|
||
def info do | ||
%{ | ||
title: "Queries that have the highest frequency of execution", | ||
index: 21, | ||
order_by: [calls: :desc], | ||
default_args: [limit: 10], | ||
columns: [ | ||
%{name: :query, type: :string}, | ||
%{name: :exec_time, type: :interval}, | ||
%{name: :prop_exec_time, type: :percent}, | ||
%{name: :calls, type: :integer}, | ||
%{name: :sync_io_time, type: :interval} | ||
] | ||
} | ||
end | ||
|
||
def query(args \\ []) do | ||
""" | ||
/* ECTO_PSQL_EXTRAS: Queries that have the highest frequency of execution */ | ||
SELECT query AS query, | ||
interval '1 millisecond' * total_exec_time AS exec_time, | ||
(total_exec_time/sum(total_exec_time) OVER()) AS exec_time_ratio, | ||
calls, | ||
interval '1 millisecond' * (shared_blk_read_time + shared_blk_write_time) AS sync_io_time | ||
FROM pg_stat_statements WHERE userid = (SELECT usesysid FROM pg_user WHERE usename = current_user LIMIT 1) | ||
AND query NOT LIKE '/* ECTO_PSQL_EXTRAS:%' | ||
ORDER BY calls DESC | ||
LIMIT <%= limit %>; | ||
""" | ||
|> EEx.eval_string(args) | ||
end | ||
end |
Oops, something went wrong.