← All posts
·6 min read
#postgres#database#tutorial

information_schema vs pg_catalog: Which Should You Query?

The difference between information_schema and pg_catalog in PostgreSQL: which one to use for what, performance gotchas, and common queries.

The short version

information_schema is the SQL-standard way to query metadata, portable across databases, slower, limited to what the standard defines. pg_catalog is PostgreSQL-specific, faster, more detailed, has everything. Use information_schema for simple cross-DB queries. Use pg_catalog when you need Postgres-specific details or performance.

Head-to-head comparison

Queryinformation_schemapg_catalog
List tablesSELECT table_name FROM information_schema.tablesSELECT relname FROM pg_class WHERE relkind = 'r'
List columnsSELECT column_name, data_type FROM information_schema.columnsSELECT attname, format_type(...) FROM pg_attribute
List indexesSELECT indexname FROM information_schema.statisticsSELECT indexrelname FROM pg_stat_user_indexes
Table sizeNot availableSELECT pg_total_relation_size(oid)
Table ownerNot availableSELECT pg_catalog.get_owner(c.oid)

When to use which

Use information_schema when you need portable SQL, simple queries, or readable syntax. Use pg_catalog when you need Postgres-specific info (owners, sizes, permissions), better performance, or internal system tables.

FAQ

Can I query pg_catalog from MySQL?
No. pg_catalog is PostgreSQL-specific.

Which one does pg_dump use?
pg_catalog. It needs Postgres-specific details like table OIDs and ACLs.

Can I see system tables from information_schema?
No. Use pg_catalog.pg_stat_activity for active queries, pg_catalog.pg_locks for locks.

Visualize your own database

Paste your PostgreSQL connection string and get an interactive ER diagram in under 10 seconds. No signup required.

Related guides

Try it on your database