Skip to content

Commit 81c8d4d

Browse files
authored
Merge pull request #75 from NikolayS/cursor/review-codebase-for-improvements-57c6
Review codebase for improvements
2 parents ac864a2 + eeace60 commit 81c8d4d

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ And type `:dba <Enter>` in psql. (Or `\i /path/to/postgres_dba/start.psql` if yo
112112
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:
113113

114114
```bash
115-
ssh -fNTML 9432:localhost:5432 sshusername@you-server.com
115+
ssh -fNTML 9432:localhost:5432 sshusername@your-server.com
116116
```
117117

118118
Then, just launch psql, connecting to port 9432 at localhost:
@@ -175,7 +175,7 @@ Once you added your queries, regenerate `start.psql` file:
175175
/bin/bash ./init/generate.sh
176176
```
177177

178-
Now your have the new `start.psql` and can use it as described above.
178+
Now you have the new `start.psql` and can use it as described above.
179179

180180
‼️ 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/).
181181

matviews/refresh_all.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
-- it might perform multiple iterations and eventually refreshes
44
-- all matviews (either all w/o data or absolutely all -- it's up to you).
55

6-
-- set thos to TRUE here if you need ALL matviews to be refrehsed, not only those that already have been refreshed
6+
-- set this to TRUE here if you need ALL matviews to be refreshed, not only those that already have been refreshed
77
set postgres_dba.refresh_matviews_with_data = FALSE;
88
-- alternatively, you can set 'postgres_dba.refresh_matviews_with_data_forced' to TRUE or FALSE in advance, outside of this script.
99

sql/i2_redundant_indexes.sql

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
-- Use it to see redundant indexes list
44

55
-- This query doesn't need any additional extensions to be installed
6-
-- (except plpgsql), and doesn't create anything (like views or smth)
6+
-- (except plpgsql), and doesn't create anything (like views or something)
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
@@ -37,7 +37,7 @@ index_data as (
3737
array_to_string(indclass, ', ') as opclasses
3838
from pg_index i
3939
join pg_class ci on ci.oid = i.indexrelid and ci.relkind = 'i'
40-
where indisvalid = true and ci.relpages > 0 -- raise for a DD with a lot of indexes
40+
where indisvalid = true and ci.relpages > 0 -- raise for a DB with a lot of indexes
4141
), redundant_indexes as (
4242
select
4343
i2.indexrelid as index_id,
@@ -53,10 +53,10 @@ index_data as (
5353
pg_get_indexdef(i2.indexrelid) index_def,
5454
pg_relation_size(i2.indexrelid) index_size_bytes,
5555
s.idx_scan as index_usage,
56-
quote_ident(tnsp.nspname) as formated_schema_name,
57-
coalesce(nullif(quote_ident(tnsp.nspname), 'public') || '.', '') || quote_ident(irel.relname) as formated_index_name,
58-
quote_ident(trel.relname) AS formated_table_name,
59-
coalesce(nullif(quote_ident(tnsp.nspname), 'public') || '.', '') || quote_ident(trel.relname) as formated_relation_name,
56+
quote_ident(tnsp.nspname) as formatted_schema_name,
57+
coalesce(nullif(quote_ident(tnsp.nspname), 'public') || '.', '') || quote_ident(irel.relname) as formatted_index_name,
58+
quote_ident(trel.relname) AS formatted_table_name,
59+
coalesce(nullif(quote_ident(tnsp.nspname), 'public') || '.', '') || quote_ident(trel.relname) as formatted_relation_name,
6060
i2.opclasses
6161
from
6262
index_data as i1
@@ -80,9 +80,9 @@ index_data as (
8080
and am1.amname = am2.amname -- same access type
8181
and i1.columns like (i2.columns || '%') -- index 2 includes all columns from index 1
8282
and i1.opclasses like (i2.opclasses || '%')
83-
-- index expressions is same
83+
-- index expressions are the same
8484
and pg_get_expr(i1.indexprs, i1.indrelid) is not distinct from pg_get_expr(i2.indexprs, i2.indrelid)
85-
-- index predicates is same
85+
-- index predicates are the same
8686
and pg_get_expr(i1.indpred, i1.indrelid) is not distinct from pg_get_expr(i2.indpred, i2.indrelid)
8787
), redundant_indexes_fk as (
8888
select

sql/i4_invalid_indexes.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
-- Use it to see invalid indexes list
44

55
-- This query doesn't need any additional extensions to be installed
6-
-- (except plpgsql), and doesn't create anything (like views or smth)
6+
-- (except plpgsql), and doesn't create anything (like views or something)
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

sql/i5_indexes_migration.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
-- you will drop it during the next cleanup routine procedure.
1717

1818
-- This query doesn't need any additional extensions to be installed
19-
-- (except plpgsql), and doesn't create anything (like views or smth)
19+
-- (except plpgsql), and doesn't create anything (like views or something)
2020
-- -- so feel free to use it in your clouds (Heroku, AWS RDS, etc)
2121

22-
-- It also does't do anything except reading system catalogs and
22+
-- It also doesn't do anything except reading system catalogs and
2323
-- printing NOTICEs, so you can easily run it on your
2424
-- production *master* database.
2525
-- (Keep in mind, that on replicas, the whole picture of index usage
@@ -86,7 +86,7 @@ with unused as (
8686
and am1.amname = am2.amname -- same access type
8787
and (
8888
i2.columns like (i1.columns || '%') -- index 2 includes all columns from index 1
89-
or i1.columns = i2.columns -- index1 and index 2 includes same columns
89+
or i1.columns = i2.columns -- index1 and index 2 include the same columns
9090
)
9191
and (
9292
i2.opclasses like (i1.opclasses || '%')

0 commit comments

Comments
 (0)