Updated on 2025-05-29 GMT+08:00

AI Feature Functions

gs_index_advise(text)

Description: Recommends an index for a single query statement.

Parameter: SQL statement string

Return type: record

For details, see section "DBMind: Autonomous Database O&M > AI Sub-functions of DBMind > Index-advisor: Index Recommendation > Single-Query Index Recommendation" in Feature Guide.

hypopg_create_index(text, [text])

Description: Creates a virtual index.

Parameter: (optional) character string of the statement for creating an index, level of the created virtual index

Return type: record

For details, see section "DBMind: Autonomous Database O&M > AI Sub-functions of DBMind > Index-advisor: Index Recommendation > Virtual Index" in Feature Guide.

hypopg_display_index([text])

Description: Displays information about all created virtual indexes.

Parameter: (optional) level of the virtual index to be displayed

Return type: record

For details, see section "DBMind: Autonomous Database O&M > AI Sub-functions of DBMind > Index-advisor: Index Recommendation > Virtual Index" in Feature Guide.

hypopg_drop_index(oid)

Description: Deletes a specified virtual index.

Parameter: OID of the index

Return type: Boolean

For details, see section "DBMind: Autonomous Database O&M > AI Sub-functions of DBMind > Index-advisor: Index Recommendation > Virtual Index" in Feature Guide.

hypopg_reset_index([text])

Description: Clears all virtual indexes.

Parameter: (optional) level of the virtual index to be cleared

Return type: none

For details, see section "DBMind: Autonomous Database O&M > AI Sub-functions of DBMind > Index-advisor: Index Recommendation > Virtual Index" in Feature Guide.

hypopg_estimate_size(oid)

Description: Estimates the space required for creating a specified index.

Parameter: OID of the index

Return type: int8

For details, see section "DBMind: Autonomous Database O&M > AI Sub-functions of DBMind > Index-advisor: Index Recommendation > Virtual Index" in Feature Guide.

check_engine_status(ip text, port text)

Description: Tests whether a predictor engine provides services on a specified IP address and port number.

Parameter: IP address and port number of the predictor engine.

Return type: text

This function is unavailable in the current version.

encode_plan_node(optname text, orientation text, strategy text, options text, dop int8, quals text, projection text)

Description: Encodes the plan operator information in the input parameters.

Parameter: plan operator information

Return type: text

This function is an internal function. You are advised not to use it directly.

model_train_opt(template text, model text)

Description: Trains a given query performance prediction model.

Parameters: template name and model name of the performance prediction model

Return type: startup_time_accuracy FLOAT8, total_time_accuracy FLOAT8, rows_accuracy FLOAT8, peak_memory_accuracy FLOAT8

This function is unavailable in the current version.

track_model_train_opt(ip text, port text)

Description: Returns the training log address of the predictor engine with the specified IP address and port number.

Parameter: IP address and port number of the predictor engine

Return type: text

This function is unavailable in the current version.

encode_feature_perf_hist(datname text)

Description: Encodes historical plan operators collected in the target database.

Parameter: database name

Return type: queryid bigint, plan_node_id int, parent_node_id int, left_child_id int, right_child_id int, encode text, startup_time bigint, total_time bigint, rows bigint, and peak_memory int

gather_encoding_info(datname text)

Description: Calls encode_feature_perf_hist to save the encoded data persistently.

Parameter: database name

Return type: int

db4ai_predict_by_bool (text, VARIADIC "any")

Description: Obtains a model whose return value is of the Boolean type for model inference. This function is an internal function. You are advised to use the PREDICT BY syntax for inference.

Parameter: model name and input column name of the inference task

Return type: Boolean

db4ai_predict_by_float4(text, VARIADIC "any")

Description: Obtains a model whose return value is of the float4 type for model inference. This function is an internal function. You are advised to use the PREDICT BY syntax for inference.

Parameter: model name and input column name of the inference task

Return type: float

db4ai_predict_by_float8(text, VARIADIC "any")

Description: Obtains a model whose return value is of the float8 type for model inference. This function is an internal function. You are advised to use the PREDICT BY syntax for inference.

Parameter: model name and input column name of the inference task

Return type: float

db4ai_predict_by_int32(text, VARIADIC "any")

Description: Obtains a model whose return value is of the int32 type for model inference. This function is an internal function. You are advised to use the PREDICT BY syntax for inference.

Parameter: model name and input column name of the inference task

Return type: int

db4ai_predict_by_int64(text, VARIADIC "any")

Description: Obtains a model whose return value is of the int64 type for model inference. This function is an internal function. You are advised to use the PREDICT BY syntax for inference.

Parameter: model name and input column name of the inference task

Return type: int

db4ai_predict_by_numeric(text, VARIADIC "any")

Description: Obtains a model whose return value is of the numeric type for model inference. This function is an internal function. You are advised to use the PREDICT BY syntax for inference.

Parameter: model name and input column name of the inference task

Return type: numeric

db4ai_predict_by_text(text, VARIADIC "any")

Description: Obtains a model whose return value is of the character type for model inference. This function is an internal function. You are advised to use the PREDICT BY syntax for inference.

Parameter: model name and input column name of the inference task

Return type: text

db4ai_predict_by_float8_array(text, VARIADIC "any")

Description: Obtains a model whose return value is of the character type for model inference. This function is an internal function. You are advised to use the PREDICT BY syntax for inference.

Parameter: model name and input column name of the inference task

Return type: text

gs_explain_model(text)

Description: Obtains the model whose return value is of the character type for text-based model parsing.

Parameter: model name

Return type: text

Example:

-- Create a data table.
gaussdb=# CREATE TABLE houses (
id INTEGER,
tax INTEGER,
bedroom INTEGER,
bath DOUBLE PRECISION,
price INTEGER,
size INTEGER,
lot INTEGER,
mark text
);

-- Insert training data.
gaussdb=# INSERT INTO houses(id, tax, bedroom, bath, price, size, lot, mark) VALUES
(1,590,2,1,50000,770,22100,'a+'),
(2,1050,3,2,85000,1410,12000,'a+'),
(3,20,2,1,22500,1060,3500,'a-'),
(4,870,2,2,90000,1300,17500,'a+'),
(5,1320,3,2,133000,1500,30000,'a+'),
(6,1350,2,1,90500,850,25700,'a-'),
(7,2790,3,2.5,260000,2130,25000,'a+'),
(8,680,2,1,142500,1170,22000,'a-'),
(9,1840,3,2,160000,1500,19000,'a+'),
(10,3680,4,2,240000,2790,20000,'a-'),
(11,1660,3,1,87000,1030,17500,'a+'),
(12,1620,3,2,118500,1250,20000,'a-'),
(13,3100,3,2,140000,1760,38000,'a+'),
(14,2090,2,3,148000,1550,14000,'a-'),
(15,650,3,1.5,65000,1450,12000,'a-');

-- Train the model.
gaussdb=# CREATE MODEL gs_explain
USING logistic_regression
 FEATURES size, lot
 TARGET mark
 FROM HOUSES
 WITH learning_rate=0.88, max_iterations=default;

-- Textualize the model.
gaussdb=# select *from gs_explain_model('price_model');
                        gs_explain_model
----------------------------------------------------------------
 Name: price_model                                             +
 Algorithm: logistic_regression                                +
 Query: CREATE MODEL price_model USING logistic_regression     +
  FEATURES size, lot                                           +
  TARGET mark                                                  +
  FROM HOUSES                                                  +
  WITH learning_rate=0.88, max_iterations=default;             +
 Return type: Text                                             +
 Pre-processing time: 0.000000                                 +
 Execution time: 0.000262                                      +
 Processed tuples: 15                                          +
 Discarded tuples: 0                                           +
 batch_size: 1000                                              +
 decay: 0.9500000000                                           +
 learning_rate: 0.8800000000                                   +
 max_iterations: 100                                           +
 max_seconds: 0                                                +
 optimizer: gd                                                 +
 tolerance: 0.0005000000                                       +
 seed: 1719571149                                              +
 verbose: false                                                +
 accuracy: 0.5333333611                                        +
 f1: 0.5333333611                                              +
 precision: 0.5000000000                                       +
 recall: 0.5714285970                                          +
 loss: -nan                                                    +
 weights: {1636.68648564241,-119.516647562169,1.12196231032849}+
 categories: {a+,a-}                                           +
(1 row)

gs_ai_stats_explain(text, text[])

Description: Prints the intelligent statistics of multiple columns in the corresponding table and columns.

Parameters: table name and column name collection.

Return type: text

gs_acm_analyze_workload_manual()

Description: Manually trains the cardinality estimation model based on the operator feedback data in the current database.

Parameter: none

Return type: text

gs_stat_get_acm_feedback_operator_info()

Description: Displays all operator feedback data collected in the global memory.

Parameter: none

Return type: record

gs_stat_get_sql_feedback_info()

Description: Displays the number of times that SQL statements are used and the execution time when SQL statements are used and not used within the effective range of the feedback cardinality function in the global memory.

Parameter: none

Return type: record

gs_costmodel_calibration_manual()

Description: Manually triggers operator time collection and corrects cost model parameters.

Parameter: none

Return type: text

gs_show_aplan(cstring)

Description: Views the multi-plan cache of queries cached in the current session.

Parameter: prepare name is used to search for the corresponding cache plan.

Return type: text

ai_watchdog_detection_warnings()

Description: Obtains the risk alarm information of the AI watchdog. The SYSADMIN or MONADMIN access permission is required.

Parameter: none

Return type: record

ai_watchdog_monitor_status(int)

Description: Obtains the monitoring information of the AI watchdog. The SYSADMIN or MONADMIN access permission is required.

Parameter: Returns the upper limit of the length of the monitored sequence.

Return type: record

ai_watchdog_parameters()

Description: Obtains the internal parameters or status information of the AI watchdog. The SYSADMIN or MONADMIN access permission is required.

Parameter: none

Return type: record