From eeace60c08e4b500f2d4bd09ec16fc6abe98fc96 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 25 Oct 2025 21:57:31 +0000 Subject: [PATCH] Fix typos and improve clarity in documentation and SQL scripts Co-authored-by: nik --- README.md | 4 ++-- matviews/refresh_all.sql | 2 +- sql/i2_redundant_indexes.sql | 16 ++++++++-------- sql/i4_invalid_indexes.sql | 2 +- sql/i5_indexes_migration.sql | 6 +++--- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 57dfb2f..5093e28 100644 --- a/README.md +++ b/README.md @@ -112,7 +112,7 @@ And type `:dba ` in psql. (Or `\i /path/to/postgres_dba/start.psql` if yo What to do if you need to connect to a remote Postgres server? Usually, Postgres is behind a firewall and/or doesn't listen to a public network interface. So you need to be able to connect to the server using SSH. If you can do it, then just create SSH tunnel (assuming that Postgres listens to default port 5432 on that server: ```bash -ssh -fNTML 9432:localhost:5432 sshusername@you-server.com +ssh -fNTML 9432:localhost:5432 sshusername@your-server.com ``` Then, just launch psql, connecting to port 9432 at localhost: @@ -175,7 +175,7 @@ Once you added your queries, regenerate `start.psql` file: /bin/bash ./init/generate.sh ``` -Now your have the new `start.psql` and can use it as described above. +Now you have the new `start.psql` and can use it as described above. ‼️ If your new queries are good consider sharing them with public. The best way to do it is to open a Pull Request (https://help.github.com/articles/creating-a-pull-request/). diff --git a/matviews/refresh_all.sql b/matviews/refresh_all.sql index 3412804..3579e13 100644 --- a/matviews/refresh_all.sql +++ b/matviews/refresh_all.sql @@ -3,7 +3,7 @@ -- it might perform multiple iterations and eventually refreshes -- all matviews (either all w/o data or absolutely all -- it's up to you). --- set thos to TRUE here if you need ALL matviews to be refrehsed, not only those that already have been refreshed +-- set this to TRUE here if you need ALL matviews to be refreshed, not only those that already have been refreshed set postgres_dba.refresh_matviews_with_data = FALSE; -- alternatively, you can set 'postgres_dba.refresh_matviews_with_data_forced' to TRUE or FALSE in advance, outside of this script. diff --git a/sql/i2_redundant_indexes.sql b/sql/i2_redundant_indexes.sql index a57c64f..442f1c7 100644 --- a/sql/i2_redundant_indexes.sql +++ b/sql/i2_redundant_indexes.sql @@ -3,7 +3,7 @@ -- Use it to see redundant indexes list -- This query doesn't need any additional extensions to be installed --- (except plpgsql), and doesn't create anything (like views or smth) +-- (except plpgsql), and doesn't create anything (like views or something) -- -- so feel free to use it in your clouds (Heroku, AWS RDS, etc) -- (Keep in mind, that on replicas, the whole picture of index usage @@ -37,7 +37,7 @@ index_data as ( array_to_string(indclass, ', ') as opclasses from pg_index i join pg_class ci on ci.oid = i.indexrelid and ci.relkind = 'i' - where indisvalid = true and ci.relpages > 0 -- raise for a DD with a lot of indexes + where indisvalid = true and ci.relpages > 0 -- raise for a DB with a lot of indexes ), redundant_indexes as ( select i2.indexrelid as index_id, @@ -53,10 +53,10 @@ index_data as ( pg_get_indexdef(i2.indexrelid) index_def, pg_relation_size(i2.indexrelid) index_size_bytes, s.idx_scan as index_usage, - quote_ident(tnsp.nspname) as formated_schema_name, - coalesce(nullif(quote_ident(tnsp.nspname), 'public') || '.', '') || quote_ident(irel.relname) as formated_index_name, - quote_ident(trel.relname) AS formated_table_name, - coalesce(nullif(quote_ident(tnsp.nspname), 'public') || '.', '') || quote_ident(trel.relname) as formated_relation_name, + quote_ident(tnsp.nspname) as formatted_schema_name, + coalesce(nullif(quote_ident(tnsp.nspname), 'public') || '.', '') || quote_ident(irel.relname) as formatted_index_name, + quote_ident(trel.relname) AS formatted_table_name, + coalesce(nullif(quote_ident(tnsp.nspname), 'public') || '.', '') || quote_ident(trel.relname) as formatted_relation_name, i2.opclasses from index_data as i1 @@ -80,9 +80,9 @@ index_data as ( and am1.amname = am2.amname -- same access type and i1.columns like (i2.columns || '%') -- index 2 includes all columns from index 1 and i1.opclasses like (i2.opclasses || '%') - -- index expressions is same + -- index expressions are the same and pg_get_expr(i1.indexprs, i1.indrelid) is not distinct from pg_get_expr(i2.indexprs, i2.indrelid) - -- index predicates is same + -- index predicates are the same and pg_get_expr(i1.indpred, i1.indrelid) is not distinct from pg_get_expr(i2.indpred, i2.indrelid) ), redundant_indexes_fk as ( select diff --git a/sql/i4_invalid_indexes.sql b/sql/i4_invalid_indexes.sql index 8e68c48..7da5ab4 100644 --- a/sql/i4_invalid_indexes.sql +++ b/sql/i4_invalid_indexes.sql @@ -3,7 +3,7 @@ -- Use it to see invalid indexes list -- This query doesn't need any additional extensions to be installed --- (except plpgsql), and doesn't create anything (like views or smth) +-- (except plpgsql), and doesn't create anything (like views or something) -- -- so feel free to use it in your clouds (Heroku, AWS RDS, etc) -- (Keep in mind, that on replicas, the whole picture of index usage diff --git a/sql/i5_indexes_migration.sql b/sql/i5_indexes_migration.sql index 96600b2..fc8ba46 100644 --- a/sql/i5_indexes_migration.sql +++ b/sql/i5_indexes_migration.sql @@ -16,10 +16,10 @@ -- you will drop it during the next cleanup routine procedure. -- This query doesn't need any additional extensions to be installed --- (except plpgsql), and doesn't create anything (like views or smth) +-- (except plpgsql), and doesn't create anything (like views or something) -- -- so feel free to use it in your clouds (Heroku, AWS RDS, etc) --- It also does't do anything except reading system catalogs and +-- It also doesn't do anything except reading system catalogs and -- printing NOTICEs, so you can easily run it on your -- production *master* database. -- (Keep in mind, that on replicas, the whole picture of index usage @@ -86,7 +86,7 @@ with unused as ( and am1.amname = am2.amname -- same access type and ( i2.columns like (i1.columns || '%') -- index 2 includes all columns from index 1 - or i1.columns = i2.columns -- index1 and index 2 includes same columns + or i1.columns = i2.columns -- index1 and index 2 include the same columns ) and ( i2.opclasses like (i1.opclasses || '%')