Toolvito

Calculates on this device. File exports run online.

Database Row Size Calculator

List the columns of a table, or paste its CREATE TABLE statement, and see how many bytes a row takes. For MySQL and MariaDB you get the count toward the 65,535-byte row limit, the largest record InnoDB must keep in a page (the cause of “Row size too large (> 8126)”) and the average record. For PostgreSQL you get the row laid out column by column, with the alignment padding and the number of rows in an 8 KB page.

Enter your values

The 65,535-byte limit, the InnoDB page limit and the average record.

Your values

For the size of the whole table.

Columns

As SHOW CREATE TABLE writes it; the columns of the first table are read.

More options

Your values are worked out in this browser. They are not sent to a server.

Your result will show here

Fill in the values, then choose Work out the row size.

Measure every row of a data export

Measure every row of a data export

Uses the columns of the calculation above. Choose up to 20 CSV exports of the table (UTF-8, a header row with the column names) of up to 1 GB each. Every row is measured with the rules above, and you get the average, median, 95th percentile and largest row, the bytes of each column and the largest rows as CSV files.

Or drop files here. CSV, TSV or TXT, up to 20 files, 1 GB each at most.

    Everything above is worked out in your browser. When you use this box, the files you choose and the column list above (names, types, lengths and character sets) are sent to the Toolvito server. Download the result within one hour after the job finishes. Choose Delete files now to request earlier removal. The hourly cleanup normally removes files within one to two hours after completion.

    How to use it

    1. Choose the database. Type each column with its type and length, or paste a CREATE TABLE statement and press Read the columns.
    2. For MySQL, type the average bytes of long text columns if you know them (AVG(LENGTH(column))); for PostgreSQL, the bytes of a typical value of each text column.
    3. Press Work out the row size. Add the number of rows to see the size of the whole table.
    4. To measure your real data, export the table as CSV with a header row and use the box below: every row is measured.

    How it is worked out

    • MySQL: the bytes of each type come from the MySQL 8.4 Reference Manual (13.7). The 65,535-byte limit counts the largest value of each column with its length bytes; TEXT, BLOB and JSON count 9 to 12 bytes; each nullable column one bit.
    • InnoDB (DYNAMIC and COMPACT): a 5-byte record header, the NULL bits, 1 or 2 length bytes for each variable-length value, a 6-byte transaction id and a 7-byte roll pointer, and a 6-byte row id without a primary key (17.10). Long values can go off-page: DYNAMIC keeps a 20-byte pointer, COMPACT the first 768 bytes and the pointer.
    • PostgreSQL: a 23-byte row header and a null bitmap, data from a multiple of 8, each value aligned by its type, a 1-byte length header for variable-length values shorter than 127 bytes and a 4-byte header otherwise, and 4 bytes of item identifier for each row in the page (PostgreSQL 17 documentation, 73.2 and 73.6).

    Limits

    • The page limit of InnoDB is exact here only for 16 KB pages (8,126 bytes); for other page sizes it is “slightly less than half a page”.
    • Indexes, page headers, free space in pages and PostgreSQL TOAST compression are not counted. JSON and BLOB sizes are estimates.

    Related tools