The SORT Prefilter - Usage Details

A SORT prefilter uses a collection of sorted indexes. A single sorted index is called an encoding. When creating a table that is to use a SORT prefilter, the collection of encodings to be used might be defined. If you do not specify them explicitly, a default set is created. The default set is reasonable for many applications. If it is not appropriate for your application, contact your TIBCO representative for advice on which encodings to use for your specific application.

To create the sort filter, pass an LPAR_LST_ENCODINGS in the dbpars parameter of the lkt_dbload function. Each element in the LPAR_LST_ENCODINGS lpar must be an LPAR_LST_ENCODING lpar. Within the LPAR_LST_ENCODING, there are currently two allowable lpars.

The first is LPAR_STRARR_FIELDNAMES. Each string array is a list of field names which is used for a given sort encoding. The first field name is the primary sort key, the second field is secondary, and so on. In general, you must have as many encodings as the number of fields in the table and use all important fields as the primary sort key in at least one encoding. Contact your TIBCO representative for further information on which sort of encodings to use for your specific application.

The second is LPAR_INTARR_BKWDSFLDS. Fields can also be sorted backwards (from the last characters in the field to the first). Important fields can and must be used as primary sort keys in both their forward and reverse directions. The backwards fields array, if given, must be the same length as the field names array. The integer is set to one of the field in the corresponding position in the field names array is to be sorted in the backwards direction and zero for the forward direction. If this value is not given all fields are sorted in the forward direction.

To use the SORT prefilter in a search, you might pass either LPAR_BLKARR_SORTLOOKUPFIELDS in the srchpars parameter or the LPAR_LST_DEDUPQUERY parameter in the dbpars of the lkt_dbsearch function. If neither parameter is passed, the field values is inferred from the query. If the field value inference cannot be done, an error is returned. As the SORT prefilter is predominantly used in a record linking scenario it expects a set of field values corresponding to the fields of the table. The LPAR_BLKARR_SORTLOOKUPFIELD parameter specifies these field values explicitly. The length of the array must be the same as the number of fields in the table and the order of the values must correspond to the field order when the table was defined. The LPAR_LST_DEDUPQUERY parameter in the dbpars can be used as a shortcut when a record in the same table is being matched against other records in the table. The list must contain a single LPAR_STR_RECKEY value. The fields of the record within the table to be searched identified by the key are used as the SORT prefilter look up fields.

If the SORT prefilter is enabled for a table, searches on that table use the SORT prefilter unless it is disabled using the LPAR_BOOL_SORTSEARCH option. This disabling of acceleration is effective for the current query only.

Whenever a lkt_dbsearch is done, the same Boolean parameter, LPAR_BOOL_SORTSEARCH, is returned in the stats list. This parameter is true if the SORT prefilter was employed, false otherwise.

Whenever database statistics are returned for a SORT prefilter enabled database, the value (LPAR_INT_DBIDXTOTALKBYTES) gives the total size of the SORT prefilter related data structures associated with this database.

Note: If predicate indexes also exist for the table this value also includes the space used by the predicate indexes (see Partition Indexes).