Re: Duplicate Extended Statistics

From: Holger Jakobs <holger(at)jakobs(dot)com>
To: pgsql-admin(at)lists(dot)postgresql(dot)org
Subject: Re: Duplicate Extended Statistics
Date: 2024-09-04 08:43:12
Message-ID: d89e43cc-7e3a-8346-8d5f-a310456e5995@jakobs.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Am 04.09.24 um 10:28 schrieb Asad Ali:
> Hi Ilia,
>
> In PostgreSQL, it is possible to create duplicate extended statistics
> because the system does not enforce uniqueness on statistics
> definitions. However, this is generally not recommended, as it leads
> to longer ANALYZE times, increased storage usage, potential planner
> performance impact, and unnecessary complexity. In practice,
> duplicates are rare because users and tools usually avoid redundancy,
> as there is no added benefit to having multiple identical sets of
> statistics on the same columns.
>
> Regards,
> Asad Ali
>
>
To find duplicate indexes:

SELECT  indrelid::regclass::text AS "Table Name",
        string_agg(indexrelid::regclass::text ||
          CASE WHEN indisunique
          THEN ' (UNIQUE)' ELSE ''
          END, ', ') AS "Indexes"
      FROM pg_index
      GROUP BY indrelid, indkey
      HAVING COUNT(*) > 1

--

Holger Jakobs, Bergisch Gladbach

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Asad Ali 2024-09-04 09:37:43 Re: User Privileges Issue
Previous Message Asad Ali 2024-09-04 08:28:45 Re: Duplicate Extended Statistics