Query Result Size Estimator

Estimate query result set size from row count, row width, and protocol overhead. Plan network bandwidth and client memory needs.

bytes
bytes
Mbps
bytes
Result Set Size
66.76 MB
70,001,024 bytes
Transfer Time
5.6 sec
at 100 Mbps
Compressed (est.)
20.03 MB
~70% gzip reduction
Per-Row Payload
140.0 bytes
Including overhead
Planning notes, formulas, and examples

About the Query Result Size Estimator

When you execute a database query, the result set travels from the server to the client over a network connection. The total transfer size isn't just rows multiplied by row width—protocol overhead, column metadata, framing, and serialization formats add significant extra bytes. For large result sets, this overhead determines whether a query completes in seconds or overwhelms client memory.

This calculator estimates the total result set size by multiplying estimated rows by average row size and adding protocol overhead. It helps you decide whether to paginate results, use streaming cursors, or apply server-side aggregation. Understanding result set size is essential for API design, client memory budgeting, network capacity planning, and avoiding out-of-memory errors in application code.

Whether you're building a report that returns millions of rows or designing a REST API endpoint, knowing the payload size in advance lets you make better architectural choices.

When This Page Helps

Underestimating result set size causes client-side OOM errors, network timeouts, and slow API responses. This calculator gives you a quick estimate so you can decide whether to paginate, stream, or aggregate before shipping a query to production.

How to Use the Inputs

  1. Enter the estimated number of rows the query will return.
  2. Enter the average row size in bytes (sum of selected column widths).
  3. Enter the protocol overhead per row in bytes (typically 10–50).
  4. Optionally adjust serialization format overhead (JSON, CSV, binary).
  5. Review the estimated result set size and transfer time.
  6. Decide whether to add LIMIT/OFFSET, cursors, or server-side aggregation.
Formula used
result_size = estimated_rows × avg_row_bytes + estimated_rows × protocol_overhead_per_row + fixed_overhead

Example Calculation

Result: 66.76 MB

500,000 rows × (120 + 20) bytes per row = 70,000,000 bytes (66.76 MB) plus 1 KB fixed overhead. On a 100 Mbps connection this transfers in approximately 5.3 seconds. Consider pagination or streaming for this volume.

Tips & Best Practices

  • JSON serialization can add 40–100% overhead compared to raw binary column widths.
  • Use SELECT only the columns you need—avoid SELECT * to reduce row width.
  • Streaming cursors (DECLARE CURSOR / FETCH) keep server memory low for large results.
  • LIMIT/OFFSET pagination keeps individual response sizes manageable for APIs.
  • gzip or zstd compression on the wire can reduce transfer size by 60–80% for text-heavy results.
  • Monitor pg_stat_statements or slow query logs for queries returning unexpectedly large result sets.

Result Set Size by Serialization Format

Binary protocols (PostgreSQL binary, MySQL compressed) are the most compact. Text protocols add type conversion overhead. JSON and XML are the most verbose due to repeated key names and escaping. Choose the smallest format your client library supports.

Pagination Strategies

LIMIT/OFFSET works for simple cases but becomes slow at high offsets. Keyset pagination (WHERE id > last_id ORDER BY id LIMIT n) is O(1) regardless of page depth. Cursor-based pagination maintains server-side state and is ideal for sequential scans of large result sets.

Network Bandwidth Planning

Estimate peak concurrent queries and multiply by average result set size to get peak bandwidth. A BI dashboard with 20 concurrent queries each returning 50 MB needs 1 Gbps burst capacity. Factor in compression and caching to reduce actual bandwidth consumption.

Sources & Methodology

Last updated:

Frequently Asked Questions

  • Protocol overhead includes row headers, column type descriptors, null bitmaps, length prefixes, and framing bytes. PostgreSQL's wire protocol adds roughly 10–20 bytes per row. MySQL adds 12–40 bytes. ODBC and JDBC drivers may add additional buffering.