pg_sqlog
Provide SQL interface to logs
pg_sqlog : Provide SQL interface to logs
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 6500 | pg_sqlog | pg_sqlog | 1.7 |
STAT | BSD-3-Clause | SQL |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
| ----d-- | No | No | No | Yes | no | no |
| Relationships | |
|---|---|
| Schemas | sqlog |
| Requires | file_fdw |
| See Also | log_fdw pg_stat_log logerrors pgelog file_fdw pg_csv aws_s3 pgdisablelogerror pgaudit pg_auth_mon |
CSV logging; daily rotation required.
Packages
| Linux / PG | PG19 | PG18 | PG17 | PG16 | PG15 |
|---|---|---|---|---|---|
| el8.x86_64 | N/A | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 |
| el8.aarch64 | N/A | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 |
| el9.x86_64 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 |
| el9.aarch64 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 |
| el10.x86_64 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 |
| el10.aarch64 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 |
| d12.x86_64 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 |
| d12.aarch64 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 |
| d13.x86_64 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 |
| d13.aarch64 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 |
| u22.x86_64 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 |
| u22.aarch64 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 |
| u24.x86_64 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 |
| u24.aarch64 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 |
| u26.x86_64 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 |
| u26.aarch64 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 |
Source
github.com/kouber/pg_sqlog
pg_sqlog-1.7+git20241118.b016539.tar.gz
Install
Make sure PGDG and PIGSTY repo available:
Install this extension with pig:
Create this extension with:
Usage
pg_sqlog provides a SQL interface for querying PostgreSQL CSV log files using a foreign table backed by file_fdw.
Querying Logs
Slow Query Analysis
Functions
| Function | Description |
|---|---|
sqlog.log([timestamp]) |
Returns log contents for a given day |
sqlog.set_date([timestamp]) |
Set the date for sqlog.log table queries |
sqlog.duration(text) |
Extract query duration from message (ms) |
sqlog.preparable_query(text) |
Replace arguments with ? for grouping |
sqlog.summary(text, int, int) |
Strip metadata, show first/last N chars |
sqlog.temporary_file_size(text) |
Extract temp file size from message |
sqlog.autovacuum([timestamp]) |
Autovacuum report for a given day |
sqlog.autoanalyze([timestamp]) |
Autoanalyze report for a given day |
Autovacuum Reports
Prerequisites
Required postgresql.conf settings: