Product Documentation

FairCom DB V12 Updates

Previous Topic

Next Topic

More Batch Operations Improve Network Traversal Performance

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:

  • Add
  • Get
  • Delete
  • Update

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:

ctdbSetBatchFilter()

ctdbSetBatchRangeOn()

ctdbSetBatchRangeOff()

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:

  1. Column filtering (i.e. return partial record based on specific column). Review c-treeDB - Field mask support for more details.
  2. Record filtering integrated in the BATSETX calls (record filtering was already possible but required separate C/S round trips). More details on Data Filters can be found in the FairCom DB Developer's Guide in Data Filters.
  3. Index ranges integrated in the BATSETX (index ranges were already supported but required separated C/S round trips). More details on index ranges can be found in the FairCom DB Developer's Guide in Index Ranges.

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:

  • batchmode; The Batch mode that used to be the "mode" parameter of BATSETX.
  • batchmode2; Reserved for future use.
  • siglen; The significant portion of the target keys in bytes.
  • nsegs; For Range Use, this is the number of segments specified in the target keys and, as a consequence, the number of operators. Set to 0 if range is not established by the call.
  • nfields; For Field Mask support, this is the number of fields specified in the field mask array.
  • target; For Range Use, this is the partial key target/lower-range. In standalone it must point to a buffer at minimum as large as the key in use.
  • utarget; For Range Use, this is the upper range. In standalone it must point to a buffer at minimum as large as the key in use.
  • operators; For Range Use, this is the Operators array for range; set to NULL if range is not established with this call.
  • fldmask; For Field Mask support, this is the array that specifies the field numbers (DODA position) of the field composing the partial record returned. Set to NULL if not in use.
  • filter; For Filter support, this is the data filter to establish. Set to NULL if no filter should be established, in which case any active filter may apply.

The use of BAT_EXTENSIONS is not compatible with the following modes:

  • BAT_DEL
  • BAT_UPD
  • BAT_INS
  • BAT_RPOS
  • BAT_KEYS

TOCIndex