KI_START_ON
Argument | Enumeration | Purpose |
---|---|---|
handle | Table handle | |
keys$ | Compound row key | |
path | Key path | |
nCols | Number of significant columns in a compound key | |
max_rows | Max rows to return | |
bSkipMatch | Skip matching row | |
sql | SQL Where Handle | |
status | KDB_ERROR_ENUM | Return status |
KI_START_ON
This function is very similar to KI_START with the difference that it requires the specified number of leading key columns nCols in a compound key to exactly match for a row to be included in the result set.
This type of operation is often used in simulating a join operation between two tables. A secondary table may have a compound key composed of two columns, the first of which is the primary key of the main table and the second of which is a unique identifier. KI_START_ON is intended to be used to filter out a result set where all the rows have the same primary key.
When used against an SQL database table on an index with a compound key KI_START_ON has significant performance advantages over the open ended KI_START and by providing this alternative rowset based code can be optimized for both native KDB and SQL without resorting to platform specific SQL.
If the column count nCols is zero then all the key columns must exactly match. If non-zero then the first nCols segments in the index key must match exactly and the remaining segments are ignored.
If the optional bSkipMatch flag is set to TRUE then the first rows in the result set are not returned if they match the supplied key. For positive path values a subsequent KI_READ_NEXT will read the first row with a key greater than the supplied key. For negative path values a subsequent KI_READ_NEXT a subsequent KI_READ_NEXT on the same negative path will read the last row with a key less than the supplied key.
Compatibility
As of KCML 6.60, all the functionality of KI_START_ON is available in KI_START and KI_START_ROW by setting the bClosed argument to TRUE. KI_START_ROW is to be preferred in new applications as the use of a row buffer allows KCML to specify the number of columns required which has performance advantages in 2-tier SQL databases.