Skip to content

Commit 4c492ea

Browse files
authored
Update postgres_unindexed_foreign_keys.sql
Add index name to suggestion
1 parent 3c36cb4 commit 4c492ea

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

postgres/postgres_unindexed_foreign_keys.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ WITH y AS (
2121
pg_catalog.quote_ident(a2.attname) AS referenced_column,
2222
pg_relation_size(pg_catalog.format('%I.%I', n1.nspname, c1.relname)) AS referencing_tbl_bytes,
2323
pg_relation_size(pg_catalog.format('%I.%I', n2.nspname, c2.relname)) AS referenced_tbl_bytes,
24-
pg_catalog.format($$CREATE INDEX ON %I.%I(%I);$$, n1.nspname, c1.relname, a1.attname) AS suggestion
24+
pg_catalog.format($$CREATE INDEX %I_idx ON %I.%I(%I);$$, t.conname, n1.nspname, c1.relname, a1.attname) AS suggestion
2525
FROM
2626
pg_catalog.pg_constraint t
2727
JOIN pg_catalog.pg_attribute a1 ON a1.attrelid = t.conrelid
@@ -59,4 +59,4 @@ ORDER BY
5959
referencing_tbl,
6060
referenced_tbl,
6161
referencing_column,
62-
referenced_column;
62+
referenced_column;

0 commit comments

Comments
 (0)