2016-05-27 11:13:36 -05:00
|
|
|
.. _index_dialog:
|
|
|
|
|
2018-06-15 03:14:12 -05:00
|
|
|
*********************
|
|
|
|
`Index Dialog`:index:
|
|
|
|
*********************
|
2018-01-11 10:58:30 -06:00
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
Use the *Index* dialog to create an index on a specified table or materialized
|
|
|
|
view.
|
2016-05-27 11:13:36 -05:00
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
The *Index* dialog organizes the development of a index through the following
|
|
|
|
dialog tabs: *General* and *Definition*. The *SQL* tab displays the SQL code
|
|
|
|
generated by dialog selections.
|
2016-05-27 11:13:36 -05:00
|
|
|
|
|
|
|
.. image:: images/index_general.png
|
2018-01-11 10:58:30 -06:00
|
|
|
:alt: Index dialog general tab
|
2019-03-08 09:29:05 -06:00
|
|
|
:align: center
|
2016-05-27 11:13:36 -05:00
|
|
|
|
|
|
|
Use the fields in the *General* tab to identify the index:
|
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
* Use the *Name* field to add a descriptive name for the index. The name will
|
|
|
|
be displayed in the *pgAdmin* tree control.
|
|
|
|
* Use the drop-down listbox next to *Tablespace* to select the tablespace in
|
|
|
|
which the index will reside.
|
2016-05-27 11:13:36 -05:00
|
|
|
* Store notes about the index in the *Comment* field.
|
|
|
|
|
|
|
|
Click the *Definition* tab to continue.
|
|
|
|
|
|
|
|
.. image:: images/index_definition.png
|
2018-01-11 10:58:30 -06:00
|
|
|
:alt: Index dialog definition tab
|
2019-03-08 09:29:05 -06:00
|
|
|
:align: center
|
2016-05-27 11:13:36 -05:00
|
|
|
|
2018-01-11 10:58:30 -06:00
|
|
|
Use the fields in the *Definition* tab to define the index:
|
2016-05-27 11:13:36 -05:00
|
|
|
|
|
|
|
* Use the drop-down listbox next to *Access Method* to select an index type:
|
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
* Select *btree* to create a B-tree index. A B-tree index may improve
|
|
|
|
performance when managing equality and range queries on data that can be
|
|
|
|
sorted into some ordering (the default).
|
|
|
|
* Select *hash* to create a hash index. A hash index may improve
|
|
|
|
performance when managing simple equality comparisons.
|
|
|
|
* Select *gist* to create a GiST index. A GiST index may improve
|
2020-09-08 01:34:58 -05:00
|
|
|
performance when managing two-dimensional geometric data types and
|
|
|
|
nearest-neighbor searches.
|
|
|
|
* Select *gin* to create a GIN index. A GIN index may improve
|
2019-03-08 09:29:05 -06:00
|
|
|
performance when managing values with more than one key.
|
|
|
|
* Select *spgist* to create a space-partitioned GiST index. A SP-GiST index
|
|
|
|
may improve performance when managing non-balanced data structures.
|
|
|
|
* Select *brin* to create a BRIN index. A BRIN index may improve
|
|
|
|
performance when managing minimum and maximum values and ranges.
|
|
|
|
|
|
|
|
* Use the *Fill Factor* field to specify a fill factor for the index. The fill
|
|
|
|
factor specifies how full the selected method will try to fill each index
|
|
|
|
page.
|
|
|
|
* Move the *Unique?* switch to the *Yes* position to check for duplicate values
|
|
|
|
in the table when the index is created and when data is added. The default is
|
|
|
|
*No*.
|
|
|
|
* Move the *Clustered?* switch to the *Yes* position to instruct the server to
|
|
|
|
cluster the table.
|
|
|
|
* Move the *Concurrent build?* switch to the *Yes* position to build the index
|
|
|
|
without taking any locks that prevent concurrent inserts, updates, or deletes
|
|
|
|
on the table.
|
|
|
|
* Use the *Constraint* field to provide a constraint expression; a constraint
|
|
|
|
expression limits the entries in the index to those rows that satisfy the
|
|
|
|
constraint.
|
|
|
|
|
|
|
|
Use the context-sensitive fields in the *Columns* panel to specify which
|
|
|
|
column(s) the index queries. Click the *Add* icon (+) to add a column:
|
|
|
|
|
|
|
|
* Use the drop-down listbox in *Column* field to select the name of the column
|
|
|
|
rom the table.
|
|
|
|
* If enabled, use the drop-down listbox to select an available *Operator class*
|
|
|
|
to specify the type of action performed on the column.
|
2016-05-27 11:13:36 -05:00
|
|
|
* If enabled, move the *Sort order* switch to specify the sort order:
|
|
|
|
|
|
|
|
* Select *ASC* to specify an ascending sort order (the default);
|
|
|
|
* Select *DESC* to specify a descending sort order.
|
2018-01-11 10:58:30 -06:00
|
|
|
|
2016-05-27 11:13:36 -05:00
|
|
|
* If enabled, move the *Nulls* switch to specify the sort order of nulls:
|
|
|
|
|
|
|
|
* Select *First* to specify nulls sort before non-nulls;
|
|
|
|
* Select *Last* to specify nulls sort after non-nulls (the default).
|
2018-01-11 10:58:30 -06:00
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
* Use the drop-down listbox in the *Collation* field to select a collation to
|
|
|
|
use for the index.
|
2016-05-27 11:13:36 -05:00
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
Use *Include columns* field to specify columns for *INCLUDE* clause of the
|
|
|
|
index. This option is available in Postgres 11 and later.
|
2018-07-19 07:13:37 -05:00
|
|
|
|
2016-05-27 11:13:36 -05:00
|
|
|
Click the *SQL* tab to continue.
|
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
Your entries in the *Index* dialog generate a SQL command (see an example
|
|
|
|
below). Use the *SQL* tab for review; revisit or switch tabs to make any
|
|
|
|
changes to the SQL command.
|
2016-05-27 11:13:36 -05:00
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
Example
|
|
|
|
*******
|
2016-05-27 11:13:36 -05:00
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
The following is an example of the sql command generated by user selections in
|
|
|
|
the *Index* dialog:
|
2016-05-27 11:13:36 -05:00
|
|
|
|
|
|
|
.. image:: images/index_sql.png
|
2018-01-11 10:58:30 -06:00
|
|
|
:alt: Index dialog sql tab
|
2019-03-08 09:29:05 -06:00
|
|
|
:align: center
|
2016-05-27 11:13:36 -05:00
|
|
|
|
2021-09-26 11:33:11 -05:00
|
|
|
The example shown demonstrates creating an index named *index_sal* that indexes
|
|
|
|
the values in the *job* column of the *jobhist* table.
|
2018-01-11 10:58:30 -06:00
|
|
|
|
2019-03-08 09:29:05 -06:00
|
|
|
* Click the *Info* button (i) to access online help.
|
2016-05-27 11:13:36 -05:00
|
|
|
* Click the *Save* button to save work.
|
2021-09-26 11:33:11 -05:00
|
|
|
* Click the *Close* button to exit without saving work.
|
2020-09-08 01:34:58 -05:00
|
|
|
* Click the *Reset* button to restore configuration parameters.
|