Set the allocation block size for this class.
MCO_RET classname_set_allocation_block_size(
/*IN*/ mco_trans_h t,
/*IN*/ mco_size_t block_size );
t
mco_trans_start().block_size
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.
MCO_S_OK
MCO_E_DISK_*
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 );
...
}
}