How Large will a Table be - Kdb+ / qStudio

Home Forums Kdb+ / qStudio How Large will a Table be


Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #110954


    Wondering if there is some function of good method of estimating how much space a live table with varying types, and a varying number of rows will take once you save it.

    Is there a way to determine how much memory a table or object is currently using?
    So we can get an idea of what it’s size will be when written to disk.


    -22! can be used to get the size of a table in memory, which will be very close to the on-disk space needed:
    q)-22!([] a:til 1000)
    q)-22!([] a:til 2000)
    q)`:/temp/a set ([] a:til 2000) / save to file
    / hcount returns size of file on disk
    q)hcount `:/temp/a

    For the larger question of estimating database requirements:

    Notice in the data types table there’s a size column:

    To estimate storage requirements:
    Design your tables and what columns they contain.
    Then for each table:
    1. Multiply the size in bytes for each type to get the number of bytes needed per row.
    2. Estimate the number of rows you will have now? 1 year from now? 2 years from now? As you want to be careful not just of the data size now but of of data growth rates.
    3. Multiply the estimated size of a row by the number of rows forecast. To get the space requirements for that one table.
    4. Total the values of all tables (and multiply by 1.5 for safety 🙂

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.