Presently, subqueries and aggregate expressions are also forbidden in WHERE. The expression used in the WHERE clause can refer only to columns of the underlying table, but it can use all columns, not just the ones being indexed. Another possible application is to use WHERE with UNIQUE to enforce uniqueness over a subset of a table. For example, if you have a table that contains both billed and unbilled orders where the unbilled orders take up a small fraction of the total table and yet that is an often used section, you can improve performance by creating an index on just that portion. A partial index is an index that contains entries for only a portion of a table, usually a portion that is more useful for indexing than the rest of the table. When the WHERE clause is present, a partial index is created. Users can also define their own index methods, but that is fairly complicated. PostgreSQL provides the index methods B-tree, hash, GiST, SP-GiST, GIN, and BRIN. For example, an index computed on upper(col) would allow the clause WHERE upper(col) = 'JIM' to use an index. This feature can be used to obtain fast access to data based on some transformation of the basic data. Multiple fields can be specified if the index method supports multicolumn indexes.Īn index field can be an expression computed from the values of one or more columns of the table row. The key field(s) for the index are specified as column names, or alternatively as expressions written in parentheses. Indexes are primarily used to enhance database performance (though inappropriate use can result in slower performance). CREATE INDEX constructs an index on the specified column(s) of the specified relation, which can be a table or a materialized view.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |