# Database Parameters

> The runtime settings for the database being opened by `mco_db_open_dev()` are defined in the `mco_db_params_t` parameter params which is a structure whose elements are defined in the following table. (Please use the following links for descriptions of common settings for in-memory or for persistent databases.)

> The `mco_db_params_t` structure is defined in `mco.h` as follows:

>         typedef struct mco_db_params_t_ {
>             uint2            mark;                    /**/
>             uint2            mem_page_size;           /* memory page size */
>             uint4            disk_page_size;          /* disk page size, typical 4096 bytes, set to zero for in-memory only database */
>             uint4            db_max_connections;      /* max number of connections */
>             mco_offs_t       disk_max_database_size;  /* max size of persistent database */
>             mco_offs_t       file_extension_quantum;  /* quantum of increasing size of the database file
>                                     (can help to reduce file fragmentation) */
>             MCO_LOG_TYPE     db_log_type;             /* database logging method */
>             uint2            connection_context_size; /* recovery connection context */
>             uint2            hash_load_factor;        /* criteria of hash reallocation in percent of used items */
>             uint2            index_optimistic_lock_threshold; /* maximum number of active write transactions when optimistic locking of B-Tree
>                                   indexes can be performed */
>             mco_log_params_t log_params;              /* initial log settings */
>             int              mode_mask;               /* open mode mask */
>             int              min_conn_local_pages;    /* minimal number of pages in per-connection allocator */
>             int              max_conn_local_pages;    /* maximal number of pages in per-connection allocator */
>             int              allocation_bitmap_caching_priority; /* priority of allocator bitmap pages in LRU page pool */
>             int              index_caching_priority;  /* priority of indices pages in LRU page pool */
>             int              object_caching_priority; /* priority of objects (non-blob) pages in LRU page pool */
>             struct mco_ddl_dictionary_t_* ddl_dict;
>             mco_size_t       ddl_dict_size;
>             int              ddl_dict_flags;
>             char*            cipher_key;             /* database encryption key */
>             mco_bool         dynamic_hash;           /* dynamically extend hash table when number of items exceeds load factor */
>             char*            license_key;            /* eXtremeDB license key */
>             int              max_classes;            /* used to reserve space for classes in database header to allow dynamic table creation */
>             int              max_indexes;            /* used to reserve space for indexes in database header to allow dynamic table creation */
>             mco_size_t       autocompact_threshold;  /* size of object after reaching which mco_w_compact is called during transaction commit */
>             MCO_TRANS_SCHED_POLICY trans_sched_policy; /* scheduling policy for transactions with the same priority */
>             uint8            max_trans_time;         /* maximal transaction time, 0 to disable */
>             int              max_active_pages;       /* maximal number of pages accessed by connection */
>             int              page_hash_bundles;      /* number of bundles in encryption/protection/compression page hash */
>             int              compression_level;      /* compression level: 0..9, 0 - no compression, -1: default compression level */
>             int              compression_mask;       /* bitmap of page kinds which should be compressed */
>             int              expected_compression_ratio;   /* use to allocate page map: virtual database space can not be larger than physical */
>                                 /* size compression ratio                                                           */
>             uint1            btree_cursor_read_ahead_size; /* number of keys taken from leaf B-Tree page at each access, can not be larger     */
>                                 /* than MCO_CFG_CURSOR_BUF_SIZE                                                     */
>             int              mvcc_bitmap_size;       /* MVCC bitmap size should be power of two */
>             int              additional_heap_size;   /* heap memory used by various internal DB functionalities, mostly for buffering during   */
>                             /* XML export/import and database save/load operations                                    */
>             mco_size_t       cow_pagemap_size;       /* Size of copy-on-write MVCC pagemap (in bytes, one byte per disk page) */
>             mco_size_t       backup_map_size;        /* size of backup counters array, bytes, power of two, ignored if disk_max_database_size set */
>                             /* set to zero to disable backup feature */
>             unsigned int     backup_min_pages;       /* number of pages for last exclusive pass of backup procedure */
>                                 /* set to zero to disable threshold */
>             unsigned int     backup_max_passes;      /* max number of passes before exclusive pass of backup procedure */
>             char             backup_map_filename[MCO_MAX_FILE_NAME]; /* name of a file will be used to store backup temporary data
>                                         on mco_db_close() call eXtremeDB will use filesystem wrapper
>                                         linked into the process to store the data   optional,
>                                         set zero for default "<persistent-storage>.bmap" file
>                                         locate at the same   location as persistent storage file  */

>             uint8            iot_agent_id;
>             uint2            iot_level;
>             uint4            file_backup_delay;      /* delay in milliseconds between writing backup blocks to minimize backup impact on performance */

>         } mco_db_params_t;

> The elements of this structure are explained as follows:

> mark | Indicates that the structure has been initialized with default values through `mco_db_params_init()` (Applications should not set or modify this field)
> mem_page_size | The size of the memory page for a conventional or shared memory device (i.e. `dev.type=MCO_MEMORY_CONV` or `dev.type=MCO_MEMORY_NAMED`). (For persistent and mixed mode databases, the value must be a power of two) (See Creating Databases)
> disk_page_size | The size of the persistent storage page for this database; (should be set to zero for all-in-memory databases). Must be a power of two and at least eight times the `mem_page_size` (See Creating Databases)
> db_max_connections | The maximum number of connections to this database (See Creating Databases)
> disk_max_database_size | The max disk space required if a persistent database (See Creating Databases)
> file_extension_quantum | The allocation block size for the database runtime to use when increasing the size of the database file (can help to reduce file fragmentation)
> db_log_type | The database log file type desired if this is a persistent database. Must be one of the following values: `REDO_LOG` , `UNDO_LOG` or `NO_LOG`. (See Log File Types and Persistent Media I/O)
> connection_context_size | Indicates by how much the runtime increases the size of the connection structure to hold any application-specific data (referred to as the application’s context). The database runtime uses this memory to copy the data pointed to by the context parameter of `mco_db_connect_ctx()`. The application context can be anything. The context is required for the recovery process to verify that the task which has created the connection is alive. (See Recovery from Failed Processes)
> dynamic_hash | A boolean value determining if dynamic hash table extension is enabled (default) or not. (See Hash Indexes)
> hash_load_factor | The factor used to determine when a hash index table is extended. Indicates the percent of used items in the hash table. (See Hash Indexes)
> index_optimistic_lock_threshold | The maximum number of active write transactions when optimistic locking of B-Tree indexes is being performed. (See MVCC Locking Optimization)
> log_params | Initial log settings specified in the `mco_log_params_t`.
> mode_mask | The database open mode flags. These mode mask options are defined in file `mco.h`. (See Database Open Modes)
> min_conn_local_pages | The minimum number of pages held by the per-connection allocator in MVCC mode. (See In-memory Page allocation)
> max_conn_local_pages | The maximum number of pages held by the per-connection allocator in MVCC mode. (See In-memory Page allocation)
> allocation_bitmap_caching_priority | The cache priority for allocation bitmap pages; an integer value zero or greater. The higher the value the longer the allocation bitmap pages will remain in the cache. (See Prioritized Cache)
> index_caching_priority | The cache priority for index pages; an integer value zero or greater. The higher the value the longer the index pages will remain in the cache. (See Prioritized Cache)
> object_caching_priority | The cache priority for database objects (excluding BLOBs); an integer value zero or greater. The higher the value the longer the object pages will remain in the cache. (See Prioritized Cache)
> ddl_dict | Reserved for future use.
> ddl_dict_size | Used to reserve space for the dictionary in the database header to allow dynamic schema modification. (This is commonly done via SQL `create table` or `alter table` operations. So this parameter has no relevance for non-SQL applications).
> ddl_dict_build_flags | Reserved for future use.
> cipher_key | Enables database encryption. (See Database Encryption)
> license_key | eXtremeDB license key.
> max_classes | Used to reserve space for classes in the database header to allow dynamic schema modification. (This is commonly done via SQL `create table` or `alter table` operations. So this parameter has no relevance for non-SQL applications).
> max_indexes | Used to reserve space for indexes in the database header to allow dynamic schema modification (This is commonly done via SQL `create table` or `alter table` operations. So this parameter has no relevance for non-SQL applications).
> autocompact_threshold | Size of an object (in bytes) after reaching which `mco_autocompact()` is called during a transaction commit. (See Automatic De-fragmentation of Dynamic Objects)
> trans_sched_policy | Scheduling policy for transactions with the same priority. (See MURSIW transaction scheduling policies)
> max_trans_time | Maximum transaction time for special system level debugging. Note that the `max_trans_time` setting has no effect except in a special build of the eXtremeDB runtime.
> max_active_pages | Maximum number of pages (default is 32) in the page hash used internally by the eXtremeDB runtime when encryption protection or data compression is enabled. (See Database Encryption)
> page_hash_bundles | Number of bundles in the page hash used internally by the eXtremeDB runtime when encryption protection or data compression is enabled. (See Database Encryption)
> compression_level | Compression level: 0 = no compression, 1 = compression enabled (default) . (See Database Encryption)
> compression_mask | A bitmap indicating the kinds of pages that are to be compressed. (See Database Compression)
> expected_compression_ratio | Used to allocate the page map (default = 10). It is not recommended to change this value. (See Database Compression)
> btree_cursor_read_ahead_size | Number of keys taken from a leaf of a B-Tree page on each access. (Cannot be larger than 10). (See B_Tree read-ahead buffering)
> mvcc_bitmap_size | The size of a bitmap used internally to accelerate the performance of the MVCC transaction manager in some cases. The default value is 0 which disables this feature. (See Accelerating MVCC performance)
> additional_heap_size | Heap memory used by various internal DB functionalities.
> cow_pagemap_size | Size of copy-on-write MVCC page map (in bytes, one byte per disk page).
> backup_map_size | Size of backup counters array, bytes, power of two, ignored if `disk_max_database_size` is set (set to zero to disable backup feature). (See Incremental Backup Implementation)
> backup_min_pages | Number of pages for last exclusive pass of backup procedure (set to zero to disable threshold). (See Incremental Backup Implementation)
> backup_max_passes | Max number of passes before exclusive pass of backup procedure. (See Incremental Backup Implementation)
> backup_map_filename | The name of a file will be used to store backup temporary data on `mco_db_close()` call eXtremeDB will use the file system wrapper linked into the process to store the data. Can be set to zero to default to "<persistent-storage>.bmap" to locate the file at the same location as the persistent storage file. (See Incremental Backup Implementation)
> iot_agent_id | The IoT agent Identifier
> iot_level | The IoT level that allows overriding the router's level defined in the MCO schema file
> file_backup_delay | The delay in milliseconds between writing backup blocks; to minimize backup impact on performance; default is 0 - no delay. (See File Backup)