Skip to content

wrong join for index bloat #19

@mrc-mm

Description

@mrc-mm

Hi, There is (IMO) a2 wrong joins in second block.
should be
JOIN btree_index_atts AS ind_atts ON pg_attribute.attrelid = ind_atts.indrelid AND pg_attribute.attnum = ind_atts.attnum
instead of
JOIN btree_index_atts AS ind_atts ON pg_attribute.attrelid = ind_atts.indexrelid AND pg_attribute.attnum = ind_atts.attnum

the following join, Is aso wrong. I use:

LEFT JOIN pg_stats ON pg_stats.schemaname = ind_atts.nspname
-- stats for regular index columns
AND ( (pg_stats.tablename = ind_atts.tablename AND pg_catalog.pg_get_indexdef(ind_atts.indexrelid, pg_attribute.attnum, TRUE) ~ pg_stats.attname)
-- stats for functional indexes
OR (pg_stats.tablename = ind_atts.index_name AND pg_stats.attname = pg_attribute.attname))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions