Update : Q simplification when experimenting with the psqlfollowing:
For the following Django model:
class Book(models.Model):
name = models.TextField(unique=True)
pg_dump (PostgreSQL 9.3) shows the following table and limitations:
CREATE TABLE book (
id integer NOT NULL,
name text NOT NULL,
);
ALTER TABLE ONLY book ADD CONSTRAINT book_name_key UNIQUE (name);
CREATE INDEX book_name_like ON book USING btree (name text_pattern_ops);
But the PostgreSQL documentation says:
PostgreSQL automatically creates a unique index when a unique Constraint [...] is defined for the table.
[...] there is no need to manually create indexes for unique columns; it is just a duplicate of an automatically generated index.
: Django ? , , text_pattern_ops, Django . unique=True Django :
CREATE UNIQUE INDEX book_name_like ON book USING btree (name text_pattern_ops);
UNIQUE . , UNIQUE INDEX text_pattern_ops , UNIQUE.