PostgreSQL COUNT(*) Performance
PostgreSQL COUNT(*) Performance is a SQL statement in the PostgreSQL Specific category. PostgreSQL COUNT(*) without WHERE does a sequential scan (slow for large tables). Use estimates or triggers for fast counts. The syntax is SELECT COUNT(*) FROM t;. It returns row count. A close relative is SERIAL, which postgreSQL auto-increment type. Creates an INTEGER column with a sequence. Equivalent to AUTO_INCREMENT in MySQL. A close relative is RETURNING, which postgreSQL extension that returns values from INSERT/UPDATE/DELETE statements (like OUTPUT in SQL Server). A close relative is ARRAY, which postgreSQL supports array columns and array operations. Can be multi-dimensional. More about this category: PostgreSQL-specific features — SERIAL, RETURNING, ARRAY, JSONB, UPSERT. Related PostgreSQL Specific entries: SERIAL, RETURNING, ARRAY, JSONB, UPSERT (INSERT ON CONFLICT), ILIKE, BIGSERIAL / SMALLSERIAL, GENERATED AS IDENTITY. This page is part of the free SQL Reference documentation covering 762+ statements, functions, and clauses, each with syntax, parameters, return values, and examples for MySQL, PostgreSQL, SQL Server, and SQLite.