Skip to content

Commit 350ca05

Browse files
authored
Merge pull request #83 from NikolayS/polish-safe
style: fix typos, update terminology, remove dead code
2 parents 40848ba + 07a53f9 commit 350ca05

14 files changed

Lines changed: 25 additions & 32 deletions

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ jobs:
119119
120120
echo " Testing 0_node.sql..."
121121
OUTPUT=$(PAGER=cat psql -h localhost -U dba_user -d test --no-psqlrc -f warmup.psql -f sql/0_node.sql | grep Role)
122-
if [[ "$OUTPUT" == *"Master"* ]]; then
122+
if [[ "$OUTPUT" == *"Primary"* ]]; then
123123
echo " ✓ Role test passed"
124124
else
125125
echo " ✗ Role test failed: $OUTPUT"

sql/0_node.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ select
3030
end)::int)::text || ' second')::interval)::text
3131
|| '; paused: ' || :postgres_dba_is_wal_replay_paused()::text || ')'
3232
else
33-
'Master'
33+
'Primary'
3434
end as value
3535
union all
3636
(

sql/b1_table_estimation.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
--This SQL is derived from https://github.com/ioguix/pgsql-bloat-estimation/blob/master/table/table_bloat.sql
44

55
/*
6-
* WARNING: executed with a non-superuser role, the query inspect only tables you are granted to read.
6+
* WARNING: executed with a non-superuser role, the query inspects only tables you are granted to read.
77
* This query is compatible with PostgreSQL 9.0 and more
88
*/
99

@@ -88,7 +88,7 @@ select
8888
greatest(last_autovacuum, last_vacuum)::timestamp(0)::text
8989
|| case greatest(last_autovacuum, last_vacuum)
9090
when last_autovacuum then ' (auto)'
91-
else '' end as "Last Vaccuum",
91+
else '' end as "Last Vacuum",
9292
(
9393
select
9494
coalesce(substring(array_to_string(reloptions, ' ') from 'fillfactor=([0-9]+)')::smallint, 100)

sql/b2_btree_estimation.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
-- enhanced version of https://github.com/ioguix/pgsql-bloat-estimation/blob/master/btree/btree_bloat.sql
44

5-
-- WARNING: executed with a non-superuser role, the query inspect only index on tables you are granted to read.
5+
-- WARNING: executed with a non-superuser role, the query inspects only indexes on tables you are granted to read.
66
-- WARNING: rows with is_na = 't' are known to have bad statistics ("name" type is not supported).
77
-- This query is compatible with PostgreSQL 8.2+
88

@@ -26,9 +26,9 @@ with step1 as (
2626
/* per tuple header: add IndexAttributeBitMapData if some cols are null-able */
2727
case
2828
when max(coalesce(s.null_frac,0)) = 0 then 2 -- IndexTupleData size
29-
else 2 + (( 32 + 8 - 1 ) / 8) -- IndexTupleData size + IndexAttributeBitMapData size ( max num filed per index + 8 - 1 /8)
29+
else 2 + (( 32 + 8 - 1 ) / 8) -- IndexTupleData size + IndexAttributeBitMapData size ( max num fields per index + 8 - 1 /8)
3030
end as index_tuple_hdr_bm,
31-
/* data len: we remove null values save space using it fractionnal part from stats */
31+
/* data len: we remove null values save space using its fractional part from stats */
3232
sum((1 - coalesce(s.null_frac, 0)) * coalesce(s.avg_width, 1024)) as nulldatawidth,
3333
max(case when a.atttypid = 'pg_catalog.name'::regtype then 1 else 0 end) > 0 as is_na
3434
from pg_attribute as a
@@ -47,7 +47,7 @@ with step1 as (
4747
s.schemaname = i.nspname
4848
and (
4949
(s.tablename = i.tblname and s.attname = pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, true)) -- stats from tbl
50-
OR (s.tablename = i.idxname AND s.attname = a.attname) -- stats from functionnal cols
50+
OR (s.tablename = i.idxname AND s.attname = a.attname) -- stats from functional cols
5151
)
5252
join pg_type as t on a.atttypid = t.oid
5353
where a.attnum > 0

sql/b3_table_pgstattuple.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
--Table bloat (requires pgstattuple; expensive)
22

3-
--https://github.com/dataegret/pg-utils/tree/master/sql
4-
--pgstattuple extension required
5-
--WARNING: without table name/mask query will read all available tables which could cause I/O spikes
3+
-- https://github.com/dataegret/pg-utils/tree/master/sql
4+
-- pgstattuple extension required
5+
-- WARNING: without table name/mask query will read all available tables which could cause I/O spikes
66
select nspname,
77
relname,
88
pg_size_pretty(relation_size + toast_relation_size) as total_size,
@@ -22,7 +22,7 @@ from (
2222
left join pg_namespace n on (n.oid = c.relnamespace)
2323
where nspname not in ('pg_catalog', 'information_schema')
2424
and nspname !~ '^pg_toast' and relkind = 'r'
25-
--put your table name/mask here
25+
-- put your table name/mask here
2626
and relname ~ ''
2727
) t
2828
order by (toast_free_space + relation_size - (relation_size - free_space)*100/fillfactor) desc

sql/b4_btree_pgstattuple.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
--B-tree indexes bloat (requires pgstattuple; expensive)
22

3-
--https://github.com/dataegret/pg-utils/tree/master/sql
4-
--pgstattuple extension required
5-
--WARNING: without index name/mask query will read all available indexes which could cause I/O spikes
3+
-- https://github.com/dataegret/pg-utils/tree/master/sql
4+
-- pgstattuple extension required
5+
-- WARNING: without index name/mask query will read all available indexes which could cause I/O spikes
66
with data as (
77
select
88
schemaname as schema_name,
@@ -25,7 +25,7 @@ with data as (
2525
join pg_class c_table on p.relid = c_table.oid
2626
where
2727
pg_get_indexdef(p.indexrelid) like '%USING btree%'
28-
--put your index name/mask here
28+
-- put your index name/mask here
2929
and indexrelname ~ ''
3030
)
3131
select

sql/i2_redundant_indexes.sql

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
-- -- so feel free to use it in your clouds (Heroku, AWS RDS, etc)
88

99
-- (Keep in mind, that on replicas, the whole picture of index usage
10-
-- is usually very different from master).
10+
-- is usually very different from the primary).
1111

1212
with fk_indexes as (
1313
select
@@ -116,12 +116,6 @@ redundant_indexes_tmp_num as (
116116
*
117117
from redundant_indexes_tmp_cut
118118
order by index_size_bytes desc
119-
), redundant_indexes_grouped as (
120-
select
121-
distinct(num),
122-
*
123-
from redundant_indexes_tmp_cut
124-
order by index_size_bytes desc
125119
)
126120
select
127121
schema_name,

sql/i4_invalid_indexes.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
-- -- so feel free to use it in your clouds (Heroku, AWS RDS, etc)
88

99
-- (Keep in mind, that on replicas, the whole picture of index usage
10-
-- is usually very different from master).
10+
-- is usually very different from the primary)..
1111

1212
select
1313
coalesce(nullif(pn.nspname, 'public') || '.', '') || pct.relname as "relation_name",

sql/i5_indexes_migration.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121

2222
-- It also doesn't do anything except reading system catalogs and
2323
-- printing NOTICEs, so you can easily run it on your
24-
-- production *master* database.
24+
-- production *primary* database.
2525
-- (Keep in mind, that on replicas, the whole picture of index usage
26-
-- is usually very different from master).
26+
-- is usually very different from the primary)..
2727

2828
-- TODO: take into account type of index and opclass
2929
-- TODO: schemas

sql/l1_lock_trees.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ with recursive l as (
2828
select (clock_timestamp() - a.xact_start)::interval(0) as ts_age,
2929
(clock_timestamp() - a.state_change)::interval(0) as change_age,
3030
a.datname,a.usename,a.client_addr,
31-
--w.obj wait_on_object,
31+
-- w.obj wait_on_object,
3232
tree.pid,replace(a.state, 'idle in transaction', 'idletx') state,
3333
lvl,(select count(*) from tree p where p.path ~ ('^'||tree.path) and not p.path=tree.path) blocked,
3434
case when tree.pid=any(tree.dl) then '!>' else repeat(' .', lvl) end||' '||trim(left(regexp_replace(a.query, e'\\s+', ' ', 'g'),100)) query

0 commit comments

Comments
 (0)