Search code examples
cassandracassandra-3.0datamodel

How do I calculate the size of a Cassandra Partition?


CREATE TABLE IF NOT EXISTS video (key int, value int, PRIMARY KEY (key, value));

Here Partition Key is key and Clustering Key is value. No regular columns. Assume, there are 1000000 rows in this partition.

What is the size of the partition?


Solution

  • To calculate the partition size, you need the following data points:

    • size of the partition key columns
    • size of static columns
    • size of cells in the partition (clustering + regular columns)
    • size of metadata overhead per row

    In your case:

    • the size the partition key (a single int column) is 4 bytes
    • the size of static columns (there are none) is 0 bytes
    • the size of the cells (clustering int + 0 regular columns) is 4 + 0 bytes
    • the size of the metadata overhead is 8 bytes on average

    So for 1M rows:

    partition size = 4B + 0B + (4B x 1,000,000 cells) + (8B x 1,000,000,000 rows)
                   = 12,000,004 bytes
                   = 11.44 MB
    

    Cheers!