Skip to content

Commit

Permalink
chore(stats): ajout d'un utilitaire pour calculer les statitiques et …
Browse files Browse the repository at this point in the history
…suivre la progression du chargement
  • Loading branch information
mborne committed Jun 10, 2024
1 parent 2a13bc6 commit ee74c01
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions bin/stats.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

PGDATABASE=${PGDATABASE:-osm}
echo "[INFO] PGDATABASE=${PGDATABASE}"

psql -d $PGDATABASE <<EOF
SELECT *, pg_size_pretty(total_bytes) AS total
, pg_size_pretty(index_bytes) AS INDEX
, pg_size_pretty(toast_bytes) AS toast
, pg_size_pretty(table_bytes) AS TABLE
FROM (
SELECT *, total_bytes-index_bytes-COALESCE(toast_bytes,0) AS table_bytes FROM (
SELECT c.oid,nspname AS table_schema, relname AS TABLE_NAME
, c.reltuples AS row_estimate
, pg_total_relation_size(c.oid) AS total_bytes
, pg_indexes_size(c.oid) AS index_bytes
, pg_total_relation_size(reltoastrelid) AS toast_bytes
FROM pg_class c
LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
WHERE relkind = 'r'
) a
) a
WHERE table_schema NOT IN ('pg_catalog','information_schema')
ORDER BY total_bytes DESC ;
EOF

0 comments on commit ee74c01

Please sign in to comment.