Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #28423 -- Updated index docs for JSONField, HStoreField and Arr… #9001

Merged
merged 1 commit into from Oct 9, 2017

Conversation

atombrella
Copy link
Contributor

@atombrella atombrella commented Sep 1, 2017

…ayField

Would it be considerable to backport this to 1.11? Both GinIndex and the class-based indexes were introduced in that release.

https://code.djangoproject.com/ticket/28423

Copy link
Member

@timgraham timgraham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unsure if repeating a similar thing three times is best approach or if a shared section would be better.

``btree`` index. This does not offer particularly significant help to querying.
A more useful index is a ``GIN`` index, which you should create using a
:class:`~django.db.migrations.operations.RunSQL` operation.
In addition to a :class:`~django.db.models.Index` or
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an Index

In addition to a :class:`~django.db.models.Index` or
:attr:`~django.db.models.Field.db_index` which will create a ``btree``
index, ``ArrayField`` can be indexed using
:class:`~django.contrib.postgres.indexes.GinIndex` or a ``gist`` index
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a gist index. The latter can be implemented with an class:~django.db.models.Index subclass.

@timgraham
Copy link
Member

We lost the advice about "This does not offer particularly significant help to querying." with regards to btree indexes. Can you give similar advice for other fields?

@atombrella
Copy link
Contributor Author

@timgraham Yes, I'll adjust it this week. I think a common section in the bottom (or top) would be fine.

@timgraham
Copy link
Member

Here's a version with some edits:

:class:`~django.db.models.Index` and :attr:`.Field.db_index` both create a
B-tree index, which isn't particularly helpful when querying complex data types.
Indexes such as :class:`~django.contrib.postgres.indexes.GinIndex` and
:class:`~django.contrib.postgres.indexes.GistIndex` are better suited, though
the index choice is dependent on the queries you're using. GiST may be a good
choice for the :ref:`range fields <range-fields>` and :class:`HStoreField`,
and GIN may be helpful for :class:`ArrayField` and :class:`JSONField`.

I don't have expertise here, but I was reading https://www.postgresql.org/docs/current/static/datatype-json.html and it seems like we should avoid making strong general recommendations (hence wording like "may be").

@timgraham
Copy link
Member

Mads, what do you think about the proposed wording?

@atombrella
Copy link
Contributor Author

LGTM. Sorry for the late follow-up. I'll push it. I was considering whether a reference to https://www.postgresql.org/docs/current/static/textsearch-indexes.html would be an idea, but it's in a chapter targeting full-text search.

@timgraham timgraham merged commit 22ff4f8 into django:master Oct 9, 2017
@atombrella
Copy link
Contributor Author

Shouldn't we do a backport of this to 1.11? I think it's just a matter of rephrasing the gist reference to a class-based index. "and a gist index are better suited ... The latter can be implemented with an class:~django.db.models.Index subclass."

@timgraham
Copy link
Member

I don't think it's particularly critical but if you want to send a PR, I'm okay to merge it. At some point (after the release of Django 2.0, I guess), the 1.11 docs are frozen except for really critical fixes. In part, that's so that we don't introduce untranslated text into the translated docs. Only the "stable" documentation receives translation updates.

@atombrella atombrella deleted the issue_28423_docs_gin_index branch October 9, 2017 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants