Search code examples
postgresqlindexingpsql

How can we get list of default indexes on primary keys used by PostgreSQL?


I want a list of default indexes built on primary keys of table used by PostgreSQL for query processing.


Solution

  • From here:

    https://www.postgresql.org/docs/current/catalog-pg-constraint.html

    SELECT 
        conname, contype, conindid::regclass 
    FROM 
        pg_constraint 
    WHERE 
        contype = 'p';
    

    Where conindid::regclass is the index name.