FairCom DB Batches provide a high capacity means to operate on multiple records at once greatly reducing network traversal time. The result for applications is higher performance. FairCom DB batches can be used in all basic database operations:
V12 enhances batch operations in all areas as described below.
Batch Filters and Range Support Added to c-treeDB Batch API
The efficiency of using ctdbSetBatch() has been greatly enhanced. Previously, several calls were required to set up a batch, run it, and tear it down. Most of these calls communicated with the FairCom Database Engine incurring network latency. Now you can set up a batch, run it, and tear it down with far fewer calls on the network. Previously a batch could take 7 calls to the FairCom Database Engine and now it can be done in as few as 2 calls.
Note: To take advantage of this feature in client/server applications, both client and server need to have the feature enabled. If one of the two does not have it enabled, an attempt to use the BAT_EXTENSIONS will fail with NSUP_ERR.
Note: This feature is a Behavior Change.
Batch-aware versions have been added:
Performing a Batch Lookup (Pseudo Code)
Performing a batch lookup in the past might have looked like this:
ctdbRecordRangeOn() |
¬ |
Network hit |
ctdbFilterRecord() |
¬ |
Network hit, setting filter |
ctdbSetBatch() |
¬ |
Network hit |
(ctdbNextBatch()) |
|
|
ctdbEndBatch() |
¬ |
Network hit |
ctdbRecordRangeOff() |
¬ |
Network hit |
ctdbFilterRecord() |
¬ |
Network hit, clearing filter |
Now it can look like this:
ctdbSetBatchRangeOn() |
¬ |
No network hit |
ctdbSetBatchFilter() |
¬ |
No network hit |
ctdbAddToFieldMask() |
¬ |
No network hit, limits fields returned allowing more records in the same buffer size |
ctdbSetBatch() |
¬ |
Network hit |
(ctdbNextBatch()) |
|
|
ctdbEndBatch() |
¬ |
Network hit |
The reduction of several network calls has proven in our testing to greatly improve the throughput capabilities with c-tree batch support.
Batch Column Filtering for Advanced Record Retrieval
Using the recently introduced c-treeDB field mask support, it is now possible to filter columns in batch operations.
In ISAM, set the fldmask member of the PKEYREQ2 structure to be used as a "request" for the BATSETX call, using the BAT_EXTENSIONS mode. The fldmask must point to an array of ULONG sorted in ascending order containing the field number (DODA position) composing the partial record. It is also necessary to set the nfields member to indicate how many entries belong to the fldmask array.
Batch Mode BAT_LOK_ONE Behavior Change
BAT_LOK_ONE (a locking mode available with DoBatchXtd()) changes the locking strategy for a batch from holding locks for the result set until the batch is completed to only holding a record lock while the record is read.
Before this modification, BAT_LOK_ONE was ignored unless BAT_PHYS was in effect.
In V12 and later, BAT_LOK_ONE is active when BAT_PHYS and/or BAT_RET_REC or BAT_RET_FIX are part of the batch request mode.
Other retrieval strategies such as BAT_RET_POS cannot be used with BAT_LOK_ONE, and the batch request will fail with a BTRQ_ERR (430).
BAT_EXTENSIONS New BATSETX (DoBatchXtd) Mode
These new features have been implemented in the FairCom DB ISAM API:
To implement the above functionality in the ISAM layer, the BAT_EXTENSIONS mode has been used. Prior to this modification, that mode returned NSUP_ERR. This mode can be now used in the "mode" parameter of the BATSETX call.
Note: BAT_EXTENSIONS cannot be OR'd with other modes, which results in an error.
When "mode" is set to BAT_EXTENSIONS, the "request parameter" is interpreted as a PKEYREQ2 structure (or a series of LONG depending on the first two LONGS which are common to the PKEYREQ2).
typedef struct pkeyreq2 {
ULONG batchmode; /* batch mode */
ULONG batchmode2; /* batch mode2 (future use) */
LONG btotal; /* total in set */
LONG bavail; /* number available */
LONG breturn; /* number returned */
COUNT siglen; /* significant key len (target/utarget size in bytes) */
COUNT nsegs; /* number of segments in range */
COUNT nfields; /* number of entries in fieldmask */
pTEXT target; /* partial key target/lower-range in standalone it must */
/* point to a buffer as large as the key (ctnum->length)*/
pTEXT utarget; /* upper-range */
pNINT operators; /* operators array for range */
pULONG fldmask; /* array of field number (DODA position) */
pTEXT filter; /* filter string in case of filter */
} PKEYREQ2;
Changes compared to the PKEYREQ used when BAT_EXTENSIONS is not in use:
The use of BAT_EXTENSIONS is not compatible with the following modes: