Index Management
Indexes are used to speed up common database operations such as combining tables or refining results. The Data Virtuality Server enables indexes on materialized tables in analytical storage to augment analytical procedures even further. For more information on how indexes are recommended, what kinds are supported, and other questions, please refer to Index Management and Recommended Indexes.
SYSADMIN.createIndex
This procedure allows you to create indexes on each materialized and custom table. For this, the data source must be set as an analytical storage or have the importer.defaultSchema property set:
CREATE FOREIGN PROCEDURE createIndex(IN recOptId biginteger, IN columnName string NOT NULL, IN indexType string, IN parentRecOptID biginteger, IN indexKind string, IN tableName string, IN nofail boolean, IN recOptUuid string, IN parentRecOptUuid string, OUT id biginteger NOT NULL RESULT)
Parameters
Parameter  | Description  | 
|---|---|
  | Specifies   | 
  | Fully qualified column name of the source table, which shall have an index on its materialized table(s)  | 
  | Type of the index to create.   | 
  | ID of the recommended optimization upon which the materialized table was created  | 
  | Current implementation knows only PostgreSQL and Oracle expression-based indexes, so the actual physical expression indexes are only being created for the mentioned DBMS.  
  | 
  | Specifies either   | 
  | Specifies if the stored procedure should fail or not in case of errors. Default:   | 
  | Specifies   | 
  | UUID of the recommended optimization upon which the materialized table was created  | 
recOptUuid and parentRecOptUuid parameters in SYSADMIN.createIndex are available since v4.1
Example
CALL SYSADMIN.createIndex(1, 'test_tables_pg.test_a.a', 'MANUAL', NULL, 'SINGLE') ;
CREATE TABLE dwh.testIndex (a integer, b integer);;
--Single kind:
CALL "SYSADMIN.createIndex"(
    "columnName" => 'a',
    "tableName" => 'dwh.testIndex'
);;
--Multiple kind:
CALL "SYSADMIN.createIndex"(
    "columnName" => 'a,b',
    "tableName" => 'dwh.testIndex',
    "indexKind"=> 'MULTIPLE'
);;
--Expression kind:
CALL "SYSADMIN.createIndex"(
    "columnName" => 'dwh.testIndex.a + dwh.testIndex.b',
    "tableName" => 'dwh.testIndex',
    "indexKind"=> 'EXPRESSION'
);;
SYSADMIN.dropIndex
SYSADMIN.dropIndex(IN recOptId biginteger, IN columnName string NOT NULL, IN indexType string, IN dropPhysical boolean, IN recOptUuid string)
Parameters
Parameter  | Description  | 
|---|---|
  | ID of the corresponding recommended optimization. If recoptID is specified, the system procedure drops an index for the corresponding recommended optimization matched with columnName and IndexType  | 
  | Fully qualified column name of the index to be dropped. Case must match the entry in the   | 
  | Type of the index to create.   | 
  | If set to  Default:   | 
  | 
  | 
The recOptId or recOptUuid must be specified.
An alternative way to drop an index is to use index id or name only as follows.
recOptUuid parameter in SYSADMIN.dropIndex is available since v4.4
SYSADMIN.dropIndexById
CREATE FOREIGN PROCEDURE dropIndexById(IN indexId biginteger NOT NULL, IN dropPhysical boolean)
SYSADMIN.dropIndexByName
CREATE FOREIGN PROCEDURE dropIndexByName(IN tableName string NOT NULL, IN indexName string NOT NULL)
Example
CALL SYSADMIN.dropIndexByName(tableName => 'dwh.testindex', indexName => 'testindex_1454927209895');;
Here, indexName is the name of the index in the DBMS. Index names are usually shown in the SYS.Keys and SYS.KeyColumns tables.
SYSADMIN.importIndex
CREATE FOREIGN PROCEDURE importIndex(IN recOptId biginteger NOT NULL, IN columnName string NOT NULL, IN indexType string, IN parentRecOptID biginteger, IN indexKind string, IN recOptUuid string, IN parentRecOptUuid string, OUT id biginteger NOT NULL RESULT)
Parameters
Parameter  | Description  | 
|---|---|
  | Specifies   | 
  | Fully qualified column name of the source table having an index on its materialized table(s)  | 
  | Type of the index to import.   | 
  | If set to  Default:   | 
  | ID of the recommended optimization upon which the materialized table was created  | 
  | Current implementation knows only PostgreSQL and Oracle expression-based indexes, so the actual physical expression indexes are only being created for the mentioned DBMS.  
  | 
  | Specifies   | 
  | UUID of the recommended optimization upon which the materialized table was created  | 
recOptUuid and parentRecOptUuid parameters in SYSADMIN.importIndex are available since v4.1
Example
CALL SYSADMIN.importIndex(2, 'test_tables_or.test_a.a,test_tables_or.test_a.b', 'MANUAL', null, 'MULTIPLE') ;
 
CALL SYSADMIN.importIndex(1, 'FLOOR(test_tables_pg.test_a.a)', 'MANUAL', null, 'EXPRESSION') ;