Skip to content

Commit 37bfcc6

Browse files
committed
ci: log postgresql slow queries >= 10ms
Signed-off-by: Anupam Kumar <kyteinsky@gmail.com>
1 parent 92de285 commit 37bfcc6

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

.github/workflows/integration-test.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,37 @@ jobs:
9292
options: --health-cmd pg_isready --health-interval 5s --health-timeout 2s --health-retries 5 --name postgres --hostname postgres
9393

9494
steps:
95+
- name: Enable PostgreSQL slow query logging and auto_explain
96+
run: |
97+
PG_CONTAINER=$(docker ps -q --filter "ancestor=pgvector/pgvector:pg17")
98+
docker exec $PG_CONTAINER bash -c "\
99+
cat >> /var/lib/postgresql/data/postgresql.conf <<EOF
100+
101+
# slow query logging
102+
log_min_duration_statement = 10
103+
104+
# auto_explain for slow queries
105+
session_preload_libraries = 'auto_explain'
106+
auto_explain.log_min_duration = '10ms'
107+
auto_explain.log_analyze = on
108+
auto_explain.log_buffers = on
109+
auto_explain.log_nested_statements = on
110+
auto_explain.log_verbose = on
111+
112+
# file-based logging
113+
logging_collector = on
114+
log_directory = '/var/log/pg_log'
115+
log_filename = 'postgresql.log'
116+
log_file_mode = 0644
117+
EOF"
118+
119+
docker exec $PG_CONTAINER psql -U root -d nextcloud -c "SELECT pg_reload_conf();"
120+
sleep 2
121+
122+
# verify the config has been loaded
123+
docker exec $PG_CONTAINER psql -U root -d nextcloud -c "SHOW log_min_duration_statement;"
124+
docker exec $PG_CONTAINER psql -U root -d nextcloud -c "SHOW session_preload_libraries;"
125+
95126
- name: Checkout server
96127
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
97128
with:
@@ -378,6 +409,12 @@ jobs:
378409
/tmp/0_pgdump_nextcloud
379410
/tmp/1_pgdump_nextcloud
380411
412+
- name: Show PostgreSQL slow query logs
413+
if: always()
414+
run: |
415+
PG_CONTAINER=$(docker ps -q --filter "ancestor=pgvector/pgvector:pg17")
416+
docker exec $PG_CONTAINER cat /var/log/pg_log/postgresql.log
417+
381418
- name: Final stats log
382419
if: always()
383420
run: |

0 commit comments

Comments
 (0)