Pg_class
PostgreSQL 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 MoreRestart All PostgreSQL Sequences with ALTER SEQUENCE
Aug 17, 2025 / · 2 min read · postgresql sql database database-maintenance postgres-sequences postgresql-scripting dba-tips database-tuning pg_class ·Restarting All PostgreSQL Sequences with SQL Script Database administrators often face challenges with PostgreSQL sequences, especially after data has been deleted or when tables have been re-imported. Sequences drive the generation of auto-incrementing values (like primary keys using SERIAL or BIGSERIAL), and …
Read MorePostgreSQL Index Cardinality: A Guide to Understanding Index Efficiency This blog post delves into the world of PostgreSQL index cardinality, a crucial metric for optimizing database performance. We'll dissect the provided SQL code, explain its purpose, and equip you with valuable insights to make informed decisions …
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 MorePostgreSQL query to find columns containing only NULL values
Mar 24, 2024 / · 3 min read · postgresql database optimization database schema design database administration pg_class pg_namespace pg_attribute pg_type pg_statistic information_schema ·Identifying Null-Only Columns in PostgreSQL This article explores a valuable PostgreSQL query for database administrators. It helps identify columns within your database tables that exclusively contain NULL values. Uncovering these "null-only" columns can be a key step in optimizing storage usage and streamlining your …
Read MoreIdentify Large PostgreSQL Indexes for Optimization
Mar 17, 2024 / · 4 min read · pg_catalog pg_indexes pg_class pg_tablespace storage optimization performance sql pg_namespace pg_sequence pg_index ·Unveiling Your PostgreSQL Indexes: A Deep Dive with Code In the realm of relational databases, efficient data retrieval is paramount. PostgreSQL achieves this partly through the magic of indexes. But have you ever wondered what lurks beneath the surface of these indexes? This post delves into a powerful Postgres …
Read More