#37197: GIS fields with Meta.Indexes creates two indexes
-----------------------------+-----------------------------------------
Reporter: David Smith | Type: Uncategorized
Status: new | Component: GIS
Version: 6.0 | Severity: Normal
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+-----------------------------------------
Given this model
{{{
from django.contrib.gis.db import models
class City(models.Model):
point = models.PointField()
class Meta:
indexes = [models.Index(fields=['point'], name='another_index')]
}}}
The output of `sqlmigrate` is the following - notice the two `CREATE
INDEX` statements:
{{{
CREATE TABLE "ticket_31252_city" ("id" bigint NOT NULL PRIMARY KEY
GENERATED BY DEFAULT AS IDENTITY, "point" geometry(POINT,4326) NOT NULL);
CREATE INDEX "ticket_31252_city_point_41eaedb4_id" ON "ticket_31252_city"
USING GIST ("point");
CREATE INDEX "another_index" ON "ticket_31252_city" USING GIST ("point");
}}}
Re-created on [
https://dryorm.xterm.info/gis-double-index dryorm].
Compare this to a non-GIS model:
{{{
from django.db import models
class City(models.Model):
point = models.CharField(max_length=100)
class Meta:
indexes = [models.Index(fields=['point'], name='another_index')]
}}}
Only a single index is created - see
[
https://dryorm.xterm.info/single_index dryorm].
Geodjango fields should only have one index created when Meta.indexes is
used, mirroring the output for non-GIS models?
--
Ticket URL: <
https://code.djangoproject.com/ticket/37197>
Django <
https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.