Information_schema
List PostgreSQL Partitioned Tables with SQL
Apr 9, 2026 / · 4 min read · postgresql administration partitioning database pg_class pg_namespace information_schema pg_inherits ·How to List PostgreSQL Partitioned Tables PostgreSQL table partitioning splits a large table into smaller physical pieces called child partitions. This improves query performance and simplifies data lifecycle management. But as a DBA, you need a quick way to see which tables in your database use partitioning — and …
Read MoreHow to Find PostgreSQL Tables Without a Primary Key A missing primary key is one of the most common and damaging database design oversights. Without a primary key, PostgreSQL has no reliable way to uniquely identify a row. This causes problems with logical replication, ORM frameworks, and application-level updates or …
Read MoreList All Views in a PostgreSQL Database with SQL
Apr 7, 2026 / · 3 min read · postgresql administration schema database information_schema pg_views pg_matviews pg_depend ·How to List All Views in a PostgreSQL Database Views are saved SQL queries stored in the database. A production database can accumulate dozens or hundreds of views over time — many created by developers, some by tools, and some that are no longer used. Knowing what views exist, which schema they belong to, and what …
Read MoreList PostgreSQL Enum Types and Their Values with SQL
Apr 6, 2026 / · 4 min read · postgresql administration schema database data types pg_type pg_enum information_schema pg_namespace ·How to List All Enum Types in a PostgreSQL Database PostgreSQL supports user-defined enum types — a fixed ordered set of string values stored efficiently as integers. Enums are common in application schemas for columns like status, role, or priority. Once created, their allowed values are managed in the database …
Read MoreList Foreign Key Constraints in PostgreSQL
Apr 5, 2026 / · 4 min read · postgresql administration schema database pg_constraint information_schema ·List Foreign Key Constraints in PostgreSQL Foreign key constraints enforce referential integrity between tables. They guarantee that a value in one table's column always has a matching row in another table. Knowing which foreign keys exist — and how they are defined — is essential before dropping tables, renaming …
Read MoreList PostgreSQL Object Comments with SQL
Apr 4, 2026 / · 4 min read · postgresql administration schema database pg_description pg_statio_all_tables information_schema pg_class pg_index pg_namespace pg_proc ·List PostgreSQL Object Comments with SQL PostgreSQL allows you to attach plain-text comments to tables, columns, indexes, functions, and other database objects using the COMMENT ON command. These comments are stored in the system catalog and are visible in psql, pgAdmin, and any tool that reads pg_description. They are …
Read MoreDetect Soft Delete Patterns in PostgreSQL
Apr 3, 2026 / · 5 min read · postgresql database administration performance autovacuum bloat information_schema pg_stat_user_tables ·Detecting Soft Delete Patterns in PostgreSQL Soft deletes are a common application pattern. Instead of removing a row with a DELETE statement, the application marks it as deleted by setting a column — typically deleted_at — to a non-null timestamp. The row stays in the table forever. The application simply filters it …
Read MoreList PostgreSQL Tables by Size with SQL
Mar 15, 2026 / · 5 min read · postgresql database administration sql queries storage performance tuning pg_class postgres dba information_schema pg_indexes pg_namespace pg_stat_user_indexes pg_stat_user_tables ·List PostgreSQL Tables by Size with SQL This PostgreSQL query lists all tables in the current database sorted by their total size, largest first. It uses pg_total_relation_size() to include the table data, indexes, TOAST storage, and free space map in the size calculation. Purpose and Overview Disk space pressure is a …
Read MorePostgreSQL Table Row Count Estimates with SQL
Mar 14, 2026 / · 4 min read · postgresql database administration sql queries performance tuning statistics pg_stat_user_tables postgres dba pg_class pg_namespace information_schema ·PostgreSQL Table Row Count Estimates with SQL This PostgreSQL query returns estimated row counts for all user tables, sorted by the largest tables first. It reads from the statistics collector rather than scanning the tables, making it near-instant even on tables with billions of rows. Purpose and Overview Counting …
Read MoreIdentify Underutilized PostgreSQL Columns for Optimization
Apr 3, 2024 / · 4 min read · PostgreSQL Database Administration Database Schema pg_class pg_namespace pg_attribute pg_type pg_statistic information_schema ·Identifying Underutilized Columns in Your PostgreSQL Database Keeping your PostgreSQL database clean and efficient is crucial for optimal performance. One way to achieve this is by identifying and potentially removing "useless" columns – those that hold minimal or redundant data. This article explores a PostgreSQL code …
Read More