KI_READ_ARRAY
Argument | Enumeration | Purpose |
---|---|---|
handle | Handle | |
SYM(keys$()) | Key array | |
path | Index path | |
SYM(rowbuf$()) | Row array | |
nRows | Rows to read | |
nReqRows | Rows to request on server | |
status | KDB_ERROR_ENUM | Return status |
nRead | Number of rows read | |
SYM(rowid$()) | Rowid array |
KI_READ_ARRAY
This is similar to KI_READ but it takes an array of keys in keys$() to populate an array of row buffers rowbuf$(). This can be a performance advantage with client-server SQL databases as it can be done in one database roundtrip.
The number of valid elements in the keys$() array is specified by the nRows argument. If missing it will be assumed to be one. Each element of the key array must be sized to the exact length of the key for that index. However if the nReqRows argument is non-zero then it will be assumed that each key is followed by the ROWID of the required row and that the lookup will be by ROWID and not key. The array elements must then be sized to the length of the key plus the length of a ROWID for that connection. The nReqRows value may exceed the nRows value and ideally should be fixed to the maximum required for all requests, including the last one. KCML will then generate identical parameterized SQL for all the requests thus maximising SQL caching and thus improving performance.
Similarly the row buffer array must be declared as an array of suitable records or views for the table and the number of elements must be nRows or more.
The number of rows actually read will be returned in the nRowsRead argument. This will be the same as nRows unless an error occurs in which case the status will be set and nRowsRead will indicate the number of rows successfully read.
The ROWIDs for the rows reads can be returned by specifying an array rowids$() of at least nRows elements with each element sized exactly to the maximum rowid size of _KDB_MAX_ROWID_LEN.
As no ordering is implied the path should be a positive number corresponding to the index for which the keys are valid.