classname_set_allocation_block_size

Set the allocation block size for this class.

Prototype

    MCO_RET classname_set_allocation_block_size(
        /*IN*/ mco_trans_h t,
        /*IN*/ mco_size_t block_size );

Arguments

t
A MCO_READ_WRITE transaction handle returned by mco_trans_start().
block_size
An integer value specifying the allocation block size.

Description

This function is generated only for persistent classes. Setting the block size appropriately makes it possible to improve sequential scan performance for persistent objects by causing instances of this class to be grouped together on persistent storage; thus reducing disk positioning overhead and keeping fragmentation at a reasonable level. The optimal size will vary depending on the expected number of objects of this class, but could be from 1 to 10 Mb.

Note that this function is not compatible with the mco_disk_database_vacuum() API because mco_disk_database_vacuum() iterates through all allocated pages (pages marked as allocated in the bitmap) and calling classname_set_allocation_block_size() actually causes the runtime to allocate the whole block only part of which is used and properly initialized.

Return Codes

MCO_S_OK
The allocation block size was set successfully.
MCO_E_DISK_*
Error codes caused by different persistent pages access failures.

Example

Schema snippet:

    declare database hybriddb;

    transient class A
    {
        unsigned<4> ui4;
        ...
    };

    persistent class B
    {
        unsigned<4> ui4;
        ...
    };

Application snippet:

    const char * db_name = "hybriddb";

    int main(int argc, char* argv[])
    {
        MCO_RET rc = MCO_S_OK;
        mco_db_h db = 0;
        mco_trans_h t;
        ...
        B b;
        ...
        {
            rc = mco_trans_start( db, MCO_READ_WRITE, MCO_TRANS_FOREGROUND, &t );

            ...

            rc = B_set_allocation_block_size( t, 1024*1024 );

            ...
        }
    }