#19441: No Postgres _like index when unique=True
----------------------------------------------+------------------------
     Reporter:  dylan@…                       |      Owner:  nobody
         Type:  Bug                           |     Status:  new
    Component:  Database layer (models, ORM)  |    Version:  1.5-beta-1
     Severity:  Normal                        |   Keywords:
 Triage Stage:  Unreviewed                    |  Has patch:  0
Easy pickings:  0                             |      UI/UX:  0
----------------------------------------------+------------------------
 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.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/19441>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to