Access method hints v16
The following hints influence how the optimizer accesses relations to create the result set.
Hint | Description |
---|---|
FULL(table) | Perform a full sequential scan on table . |
INDEX(table [ index ] [...]) | Use index on table to access the relation. |
NO_INDEX(table [ index ] [...]) | Don't use index on table to access the relation. |
In addition, you can use the ALL_ROWS
, FIRST_ROWS
, and FIRST_ROWS(n)
hints.
INDEX
and NO_INDEX
hints for the partitioned table internally expand to include the corresponding inherited child indexes and apply in later processing.
About the examples
The sample application doesn't have enough data to show the effects of optimizer hints. Thus the remainder of these examples use a banking database created by the pgbench
application located in the EDB Postgres Advanced Server bin
subdirectory.
Example: Create a sample database and tables
The following steps create a database named, bank
populated by the tables pgbench_accounts, pgbench_branches, pgbench_tellers
, and pgbench_history
. The –s 20
option specifies a scaling factor of 20, which results in the creation of 20 branches. Each branch has 100,000 accounts. The result is a total of 2,000,000 rows in the pgbench_accounts
table and 20 rows in the pgbench_branches
table. Ten tellers are assigned to each branch resulting, in a total of 200 rows in the pgbench_tellers
table.
The following initializes the pgbench
application in the bank
database.
A total of 500,00 transactions are then processed. These transactions populate the pgbench_history
table with 500,000 rows.