Informix

nested-group-icon.png

DB2

Expand all | Collapse all

Bytes per row

  • 1.  Bytes per row

    Posted 9 days ago
    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;

    Thanks
    Amit Patel



    ------------------------------
    AMIT PATEL
    ------------------------------


  • 2.  RE: Bytes per row

    Posted 9 days ago
    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.

    Art





  • 3.  RE: Bytes per row

    Posted 9 days ago
    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.

    Art





  • 4.  RE: Bytes per row

    Posted 8 days ago
    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'.

    E.g.
    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.


    HTH,
     Andreas

    ------------------------------
    Andreas Legner
    ------------------------------