Opened 12 years ago

Last modified 12 years ago

#19441 closed Bug

No Postgres _like index when unique=True — at Initial Version

Reported by: dylan@… Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords: postgresql
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

class Species(models.Model):

scientific_name = models.CharField(max_length=200, db_index=True)

Genererates 2 indexes

BEGIN;
CREATE INDEX "species_species_scientific_name" ON "species_species" ("scientific_name");
CREATE INDEX "species_species_scientific_name_like" ON "species_species" ("scientific_name" varchar_pattern_ops);

COMMIT;

class Species(models.Model):

scientific_name = models.CharField(max_length=200, unique=True, db_index=True)

Does not create any indexes, because it depends on UNIQUE, but it SHOULD generate the index

CREATE INDEX "species_species_scientific_name_like" ON "species_species" ("scientific_name" varchar_pattern_ops);

to make sure Postgres is optimized for LIKE operator.

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top