table-size

table-size -name <name> -json <string>
    [-rows <num> [[-primarykey | -index <name>] -keyprefix <size>]] 

Calculates key and data sizes for the specified table using the row input, optionally estimating the NoSQL DB cache size required for a specified number of rows of the same format. Running this command on multiple sample rows can help determine the necessary cache size for desired store performance.

  • -json specifies a sample row used for the calculation.

  • -rows specifies the number of rows to use for the cache size calculation

  • Use the -index or -primarykey and -keyprefix to specify the expected commonality of index keys in terms of number of bytes.

This command mainly does the following:

  1. Calculates the key and data size based on the input row in JSON format.

  2. Estimates the DB Cache size required for a specified number of rows in the same JSON format.

    The output contains both detailed size info for primary key/index and the total size; internally it calls JE's DbCacheSize utility to calculate the cache size required for primary key and indexes with the input parameters:

    java -jar $KVHOME/dist/lib/je.jar DbCacheSize
    -records <num> -key <size> -data <size> -keyprefix
    <size> -outputproperties -replicated <JE properties...>
    -duplicates] 

    where:

    • -records <num>: The number of rows specified by -row <num>.

    • -key <size>: The size of key get from step 1.

    • -data <size>: The size of data get from step1.

    • -keyprefix <size>: The expected commonality of keys, specified using -primarykey | -index <name> -keyprefix <size>

    • -duplicates: Used only for table index.

    • -<JE properties...>: The JE configuration parameters used in kvstore.

For example:

kv-> execute "create table user (id integer, address string,
zip_code string, primary key(id))"
kv-> execute "create index idx1 on user (zip_code)" 

See the following cases:

  1. Calculates the key size and data size based on the input row in JSON.

    kv-> table-size -name user -json '{"id":1,
    "address": "Oracle Building ZPark BeiJing China",
    "zip_code":"100000"}'
    
    === Key and Data Size ===
    
          Name         Number of Bytes
    -----------------  ---------------
    Primary Key               8
    Data                     47
    Index Key of idx1         7 
  2. Calculates the key/data size and the cache size of the table with 10000 rows.

    kv-> table-size -name user -json '{"id":1,
    "address": "Oracle Building ZPark BeiJing China",
    "zip_code":"100000"}'
    -rows 10000
    === Key and Data Size ===
    
          Name         Number of Bytes
    -----------------  ---------------
    Primary Key               8
    Data                     47
    Index Key of idx1         7
    
    === Environment Cache Overhead ===
    
    16,798,797 minimum bytes
    
    === Database Cache Sizes ===
    
    Name   Number of Bytes             Description
    -----  ---------------  ----------------------------------
                 1,024,690  Internal nodes only
    Table        1,024,690  Internal nodes and record versions
                 1,024,690  Internal nodes and leaf nodes
    -----  ---------------  ----------------------------------
                   413,728  Internal nodes only
    idx1           413,728  Internal nodes and record versions
                   413,728  Internal nodes and leaf nodes
    -----  ---------------  ----------------------------------
                 1,438,418  Internal nodes only
    Total        1,438,418  Internal nodes and record versions
                 1,438,418  Internal nodes and leaf nodes 

    For more information, see the DbCacheSize javadoc.

    Note:

    The cache size is calculated in the following way:

    • Cache size of table

      java -jar KVHOME/lib/je.jar DbCacheSize -records
         10000 key 8 -data 47 -outputproperties -replicated
         <JE properties...> 

      The parameters are:

      • Record number: 10000

      • Primary key size: 8

      • Data size: 47

    • Cache size of table

       java -jar KVHOME/lib/je.jar DbCacheSize -records
         10000 -key 7 -data 8 -outputproperties -replicated
         <JE properties...> -duplicates 

      The parameters are:

      • Record number: 10000

      • Index key size: 7

      • Data size: 8. The primary key size is used here, since the data of secondary index is the primary key.

      • Use -duplicates for index.

    • Total size = cache size of table + cache size of idx1.

  3. Calculates the cache size with a key prefix size for idx1
    kv-> table-size -name user -json
    '{"id":1, "address":"Oracle Building ZPark BeiJing China",
    "zip_code":"100000"}' -rows 10000 -index idx1 -keyprefix 3
    
    === Key and Data Size ===
    
    
          Name         Number of Bytes
    -----------------  ---------------
    Primary Key               8
    Data                     47
    Index Key of idx1         7
    
    === Environment Cache Overhead ===
    
    16,798,797 minimum bytes
    
    === Database Cache Sizes ===
    
    Name   Number of Bytes             Description
    -----  ---------------  ----------------------------------
                 1,024,690  Internal nodes only
    Table        1,024,690  Internal nodes and record versions
                 1,024,690  Internal nodes and leaf nodes
    -----  ---------------  ----------------------------------
                   413,691  Internal nodes only
    idx1           413,691  Internal nodes and record versions
                   413,691  Internal nodes and leaf nodes
    -----  ---------------  ----------------------------------
                 1,438,381  Internal nodes only
    Total        1,438,381  Internal nodes and record versions
                 1,438,381  Internal nodes and leaf nodes 

    For more information, see the DbCacheSize javadoc.

    Note:

    A key prefix size is provided for idx1, the idx1's cache size is calculated like this:

    java -jar KVHOME/lib/je.jar DbCacheSize -records
    10000 -key 7 -data 8 -keyprefix 3 -outputproperties 
    -replicated <JE properties...> -duplicates 

    The above examples show that the cache size of idx1 is 413,691 and is smaller than 413,728 of case 2. For more information about the usage of keyprefix, see JE DbCacheSize document.