#19441: No Postgres _like index when unique=True
-------------------------------------+-------------------------------------
     Reporter:  dylan@…              |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:
  (models, ORM)                      |  1.5-beta-1
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
    Has patch:  0                    |  Unreviewed
  Needs tests:  0                    |      Needs documentation:  0
Easy pickings:  0                    |  Patch needs improvement:  0
                                     |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by claudep):

 * needs_better_patch:   => 0
 * needs_tests:   => 0
 * needs_docs:   => 0


Old 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.

New description:

 {{{
 class Species(models.Model):
     scientific_name = models.CharField(max_length=200, db_index=True)
 }}}

 Generates 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#comment:1>
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