#30267: GeoDjango does not create correct PostGIS index for 3D geometry fields
--------------------------------------+------------------------------------
Reporter: Casper van der Wel | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: GIS | Version: 1.11
Severity: Normal | Resolution:
Keywords: geodjango, postgis | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Comment (by Casper van der Wel):
Thanks for the response. I tried to add a GIST index using
django.contrib.postgres.indexes. As I am using Django 1.11, I had to write
the index class. But it worked, I do not have to write raw sql anymore for
setting the 2D index.
{{{
class GistIndex(Index):
suffix = '2d'
def create_sql(self, model, schema_editor):
return super().create_sql(model, schema_editor, using=' USING
gist')
class PolyModel(models.Model):
objects = QuerySetExplain.as_manager()
geometry = models.PolygonField(srid=28992, dim=3)
class Meta:
indexes = [GistIndex(['geometry'])]
}}}
This yields a table with 2 indexes, one USING gist (geometry) and one
USING gist (geometry GIST_GEOMETRY_OPS_ND)
Replying to [comment:1 Carlton Gibson]:
> Hi Casper.
>
> Could you take a look through the
[https://docs.djangoproject.com/en/2.2/ref/contrib/postgres/indexes
/#module-django.contrib.postgres.indexes list of Postgres indexes]? There
have been additions since 1.11. #28887, #28126, adding Gist and SP-Gist
indexes in particular.
>
> Does using these with
[https://docs.djangoproject.com/en/2.1/ref/models/options/#django.db.models.Options.indexes
`Options.indexes`] solve you having to use raw SQL?
>
> (I appreciate that doesn't address your point about changing the
lookup.)
>
--
Ticket URL: <https://code.djangoproject.com/ticket/30267#comment:3>
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 unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/067.b8a7e93ccc20cc05faefe436ce20cbf0%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.