Skip to content

Add index size to the output #88

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sql/btree_indexes_on_array_columns.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ select
i.indrelid::regclass::text as table_name,
i.indexrelid::regclass::text as index_name,
col.attnotnull as column_not_null,
quote_ident(col.attname::text) as column_name,
quote_ident(col.attname) as column_name,
pg_relation_size(i.indexrelid) as index_size
from pg_catalog.pg_index i
inner join pg_catalog.pg_class ic on ic.oid = i.indexrelid
Expand Down
2 changes: 1 addition & 1 deletion sql/columns_not_following_naming_convention.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
select
t.oid::regclass::text as table_name,
col.attnotnull as column_not_null,
quote_ident(col.attname::text) as column_name
quote_ident(col.attname) as column_name
from
pg_catalog.pg_class t
inner join pg_catalog.pg_namespace nsp on nsp.oid = t.relnamespace
Expand Down
2 changes: 1 addition & 1 deletion sql/columns_with_json_type.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
select
t.oid::regclass::text as table_name,
col.attnotnull as column_not_null,
quote_ident(col.attname::text) as column_name
quote_ident(col.attname) as column_name
from
pg_catalog.pg_class t
inner join pg_catalog.pg_namespace nsp on nsp.oid = t.relnamespace
Expand Down
2 changes: 1 addition & 1 deletion sql/columns_with_serial_types.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ with
col.attrelid::regclass::text as table_name,
col.attnotnull as column_not_null,
nsp.nspname as schema_name,
quote_ident(col.attname::text) as column_name,
quote_ident(col.attname) as column_name,
case col.atttypid
when 'int'::regtype then 'serial'
when 'int8'::regtype then 'bigserial'
Expand Down
2 changes: 1 addition & 1 deletion sql/columns_without_description.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
select
pc.oid::regclass::text as table_name,
col.attnotnull as column_not_null,
quote_ident(col.attname::text) as column_name
quote_ident(col.attname) as column_name
from
pg_catalog.pg_class pc
inner join pg_catalog.pg_namespace nsp on nsp.oid = pc.relnamespace
Expand Down
4 changes: 2 additions & 2 deletions sql/duplicated_foreign_keys.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ with
c.conrelid as table_oid,
c.confrelid as foreign_table_oid,
u.attposition,
col.attname,
col.attnotnull,
quote_ident(col.attname) as column_name,
quote_ident(c.conname) as constraint_name
from
pg_catalog.pg_constraint c
Expand All @@ -33,7 +33,7 @@ with
constraint_name,
table_oid,
foreign_table_oid,
array_agg(attname::text || ',' || attnotnull::text order by attposition) as columns
array_agg(column_name || ',' || attnotnull::text order by attposition) as columns
from fk_with_attributes
group by constraint_name, table_oid, foreign_table_oid
)
Expand Down
2 changes: 1 addition & 1 deletion sql/foreign_keys_without_index.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
select
c.conrelid::regclass::text as table_name,
quote_ident(c.conname) as constraint_name,
array_agg(col.attname::text || ',' || col.attnotnull::text order by u.attposition) as columns
array_agg(quote_ident(col.attname) || ',' || col.attnotnull::text order by u.attposition) as columns
from
pg_catalog.pg_constraint c
inner join lateral unnest(c.conkey) with ordinality u(attnum, attposition) on true
Expand Down
2 changes: 1 addition & 1 deletion sql/indexes_with_boolean.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ select
pi.indrelid::regclass::text as table_name,
pi.indexrelid::regclass::text as index_name,
col.attnotnull as column_not_null,
quote_ident(col.attname::text) as column_name,
quote_ident(col.attname) as column_name,
pg_relation_size(pi.indexrelid) as index_size
from
pg_catalog.pg_index pi
Expand Down
2 changes: 1 addition & 1 deletion sql/indexes_with_null_values.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
select
i.indrelid::regclass::text as table_name,
i.indexrelid::regclass::text as index_name,
string_agg(a.attname, ', ') as nullable_fields, /* in fact, there will always be only one column */
string_agg(quote_ident(a.attname), ', ') as nullable_fields, /* in fact, there will always be only one column */
pg_relation_size(i.indexrelid) as index_size
from
pg_catalog.pg_index i
Expand Down
2 changes: 1 addition & 1 deletion sql/primary_keys_with_serial_types.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ with
col.attrelid::regclass::text as table_name,
col.attnotnull as column_not_null,
s.seqrelid::regclass::text as sequence_name,
quote_ident(col.attname::text) as column_name,
quote_ident(col.attname) as column_name,
case col.atttypid
when 'int'::regtype then 'serial'
when 'int8'::regtype then 'bigserial'
Expand Down
3 changes: 2 additions & 1 deletion sql/primary_keys_with_varchar.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

-- Finds primary keys with columns of varchar(32/36/38) type.
-- Usually this columns should use built-in uuid type.
-- Usually these columns should use built-in uuid type.
--
-- See https://www.postgresql.org/docs/17/datatype-uuid.html
-- b9b1f6f5-7f90-4b68-a389-f0ad8bb5784b - with dashes - 36 characters
Expand All @@ -15,6 +15,7 @@
select
pc.oid::regclass::text as table_name,
i.indexrelid::regclass as index_name,
pg_relation_size(i.indexrelid) as index_size,
array_agg(quote_ident(a.attname) || ',' || a.attnotnull::text order by a.attnum) as columns
from
pg_catalog.pg_class pc
Expand Down
2 changes: 1 addition & 1 deletion sql/tables_with_zero_or_one_column.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
select
pc.oid::regclass::text as table_name,
pg_table_size(pc.oid) as table_size,
coalesce(array_agg(a.attname::text || ',' || a.attnotnull::text order by a.attnum) filter (where a.attname is not null), '{}') as columns
coalesce(array_agg(quote_ident(a.attname) || ',' || a.attnotnull::text order by a.attnum) filter (where a.attname is not null), '{}') as columns
from
pg_catalog.pg_class pc
inner join pg_catalog.pg_namespace nsp on nsp.oid = pc.relnamespace
Expand Down