Expand all | Collapse all

Bytes per row

  • 1.  Bytes per row

    Posted Wed November 18, 2020 11:08 PM
    Hello All,

      I need to know how many bytes 1 row will consist?

    Will btch_name         varchar(80,50)   take 80 Bytes ?  And if this field has only 30 character then also it will space 80 bytes only?
    And if we have decimal (10,2) and decimal(2,0) then how many bytes both will have?

    create table RD_SIMD_BTCH (

    btch_numb         integer                                         not null,

    btch_name         varchar(80,50)                              not null,

    file_name           varchar(50,0)                             not null,

    mail_to               varchar(50,0)                             not null,

    clnt_id                char(1)                                      not null,

    sent_flag            char(1)                                      not null,

    resp_flag            char(1)                                      not null,

    crtd_dttm            datetime year to second                 not null,

    crtd_by              char(12)                                       not null,

    last_chng_dttm  datetime year to second                 not null,

    last_chng_by       char(12)                                       not null,


    Kindly reply;

    Amit Patel


  • 2.  RE: Bytes per row

    Posted Wed November 18, 2020 11:45 PM
    Varchat(80,50) means that unless the value is null, at least 51 bytes will be allocated with a maximum size of 81 bytes [80 characters us a one byte length byte). If null then only one byte will be stored.


  • 3.  RE: Bytes per row

    Posted Wed November 18, 2020 11:49 PM
    Oops, so decimals take up one byte foe each two digits plus one byte. So decimal(2, 0) uses two bytes, decimal(10,5) uses 6 bytes.


  • 4.  RE: Bytes per row

    Posted Thu November 19, 2020 05:09 AM
    You always can create a test table, with either the full schema or only a single column of a specifc type you're interested in.
    Then query rowsize from systables for this table, for the *maximum* row size (which is what a row would consume when loaded into session memory during query processing.)
    If variable length fields are part of your test, e.g. varchar, you then would insert a minimal test row (e.g. all fields null) and look at that row using 'oncheck -pp'.

    dbaccess stores7 <<!

    create table test_rowsize(d decimal(10,5),v varchar(80,50));

    select rowsize from systables where tabname='test_rowsize';

    insert into test_rowsize values (null,null);


    $ oncheck -pp stores7:test_rowsize 0x101

    -> slot len would be the actual space consumed by this row in the data page.


    Andreas Legner