Faster aggregation can be achieved by using a VCI defined for all columns to be referenced.
This section describes the conditions under which a scan can use a VCI.
Whether to use VCI is determined based on cost estimation in the same way as normal indexes. Therefore, another execution plan will be selected if it is cheaper than a VCI even if a VCI is available.
SQL statements that can use VCIs
In addition to general SELECT statements, VCIs can be used for the SQL statements below (as long as they do not specify any of the elements listed in "SQL statements that cannot use VCIs" below):
SELECT INTO
CREATE TABLE AS SELECT
CREATE MATERIALIZED VIEW ... AS SELECT
CREATE VIEW ... AS SELECT
COPY (SELECT ...) TO
SQL statements that cannot use VCIs
VCIs cannot be used for SQL statements that specify any of the following:
Subquery to reference the column in which the parent query is referencing is specified
Lock clause (such as FOR UPDATE)
Cursor declared with WITH HOLD or scrollable
SERIALIZABLE transaction isolation level
Function or operator listed in "Functions and operators that do not use a VCI"
User-defined function
Classification | Function/operator | |
---|---|---|
Mathematical functions and operators | Random functions | random and setseed |
String functions and operators | String functions | format (if the format argument is specified), regexp_matches, regexp_split_to_array and regexp_split_to_table |
Date/time functions and operators | Date/time functions | age(timestamp), current_date, current_time, current_timestamp, localtime, localtimestamp, statement_timestamp and transaction_timestamp |
Delaying execution functions | pg_sleep, pg_sleep_for, and pg_sleep_until | |
Enum support functions | All functions and operators | |
Geometric functions and operators | All functions and operators | |
Network address functions and operators | All functions and operators | |
Text search functions and operators | All functions and operators | |
XML functions | All functions | |
JSON functions and operators | All functions and operators | |
Sequence manipulation functions | All functions | |
Array functions and operators | All functions and operators | |
Range functions and operators | All functions and operators | |
Aggregate functions | General-purpose aggregate functions | array_agg, json_agg, json_object_agg, string_agg and xmlagg |
Aggregate functions for statistics | corr, covar_pop, covar_samp, regr_avgx, regr_avgy, regr_count, regr_intercept, regr_r2, regr_slope, regr_sxx, regr_sxy and regr_syy | |
Ordered-set aggregate functions | All functions | |
Hypothetical-set aggregate functions | All functions | |
Window functions | All functions | |
Subquery expressions | Subquery expressions with its row constructor specified on the left side | |
Row and array comparisons | Row constructor and composite type comparisons | |
Set returning functions | All functions | |
System information functions | All functions | |
System administration functions | All functions | |
Trigger functions | All functions | |
Session information functions | current_role and current_user |