Home / Companies / Yugabyte / Blog / Post Details
Content Deep Dive

Row Counts of Tables in a SQL Schema and Database: PostgreSQL vs. YugabyteDB

Blog post from Yugabyte

Post Details
Company
Date Published
Author
Karthik Ranganathan
Word Count
1,300
Company Posts That Month
14
Language
English
Hacker News Points
-
Post removed?
No
Summary

To get the total row counts of data in tables across various dimensions (per-table, per-schema, and in a given database), one can use SQL techniques that are similar for PostgreSQL and YugabyteDB. A user-defined function (UDF) named `count_rows_of_table` can be created to count the number of rows in a single table. By querying the `information_schema.tables` table and using this UDF, row counts can be obtained per-table, per-schema, and across all tables in a database. Additionally, aggregate row counts can be calculated by grouping the results by schema or by summing up the individual row counts. These techniques are useful for sanity-checking data after migrating an application from PostgreSQL to YugabyteDB and can help prevent SQL injection attacks when generating dynamic SQL queries.

Trends Found in this Post

No tracked trend matches for this post yet.

Use This Data

Use this post, company, and trend context to find content marketing opportunities, perform competitive analysis, or address product feature gaps via the Plushcap MCP server or the Plushcap API.