Indexes to Tables

* You can explicitly create indexes for table columns in PostgreSQL. Those indexes will speed up operations that look-up or sort according to values in those fields.

* The "CREATE INDEX" command is used for this purpose.

* Example:

Create an index according to the last name:

test=> CREATE INDEX employees_last_name_index
test->        ON employees
test->        ( last_name ) \g

Create an index on both the first name and last name:

test=> CREATE INDEX employees_first_and_last_name_index
test->        ON employees
test->        ( last_name, first_name ) \g

* To remove an index use the "DROP INDEX" command.

* Note: There is no "CREATE INDEX" command in the SQL 92 standard.