Home Explore Blog Models CI



postgresql

13th chunk of `doc/src/sgml/ref/create_index.sgml`
3387bfe6ac96a4c467bec310542708cb63d21a1247b4a48d00000001000008c0
 INDEX</command> with the
   <literal>CONCURRENTLY</literal> option supports parallel builds
   without special restrictions, only the first table scan is actually
   performed in parallel.
  </para>

  <para>
   Use <link linkend="sql-dropindex"><command>DROP INDEX</command></link>
   to remove an index.
  </para>

  <para>
   Like any long-running transaction, <command>CREATE INDEX</command> on a
   table can affect which tuples can be removed by concurrent
   <command>VACUUM</command> on any other table.
  </para>

  <para>
   Prior releases of <productname>PostgreSQL</productname> also had an
   R-tree index method.  This method has been removed because
   it had no significant advantages over the GiST method.
   If <literal>USING rtree</literal> is specified, <command>CREATE INDEX</command>
   will interpret it as <literal>USING gist</literal>, to simplify conversion
   of old databases to GiST.
  </para>

  <para>
    Each backend running <command>CREATE INDEX</command> will report its
    progress in the <structname>pg_stat_progress_create_index</structname>
    view. See <xref linkend="create-index-progress-reporting"/> for details.
  </para>
 </refsect1>

 <refsect1>
  <title>Examples</title>

  <para>
   To create a unique B-tree index on the column <literal>title</literal> in
   the table <literal>films</literal>:
<programlisting>
CREATE UNIQUE INDEX title_idx ON films (title);
</programlisting>
  </para>

  <para>
   To create a unique B-tree index on the column <literal>title</literal>
   with included columns <literal>director</literal>
   and <literal>rating</literal> in the table <literal>films</literal>:
<programlisting>
CREATE UNIQUE INDEX title_idx ON films (title) INCLUDE (director, rating);
</programlisting>
  </para>

  <para>
   To create a B-Tree index with deduplication disabled:
<programlisting>
CREATE INDEX title_idx ON films (title) WITH (deduplicate_items = off);
</programlisting>
  </para>

  <para>
   To create an index on the expression <literal>lower(title)</literal>,
   allowing efficient case-insensitive searches:
<programlisting>
CREATE INDEX ON films ((lower(title)));
</programlisting>
   (In this example we have chosen to omit the index name, so the system
   will

Title: CREATE INDEX: Concurrency, Removal, R-tree History, Progress Reporting, and Examples
Summary
`CREATE INDEX CONCURRENTLY` supports parallel builds, but only the first table scan is performed in parallel. Use `DROP INDEX` to remove an index. A long-running `CREATE INDEX` can affect tuples removed by concurrent `VACUUM`. Older PostgreSQL versions had an R-tree index method that has been removed; `USING rtree` is now interpreted as `USING gist`. Progress is reported in the `pg_stat_progress_create_index` view. Examples show creating unique B-tree indexes, disabling deduplication, and indexing expressions for case-insensitive searches.