mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #12234 -- Create additional indexes that use the appropriate operation class for PostgreSQL varchar and text columns when db_index=True.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@11912 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -80,6 +80,21 @@ You should also audit your existing code for any instances of this behavior
|
||||
before enabling this feature. It's faster, but it provides less automatic
|
||||
protection for multi-call operations.
|
||||
|
||||
Indexes for ``varchar`` and ``text`` columns
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
.. versionadded:: 1.1.2
|
||||
|
||||
When specifying ``db_index=True`` on your model fields, Django typically
|
||||
outputs a single ``CREATE INDEX`` statement. However, if the database type
|
||||
for the field is either ``varchar`` or ``text`` (e.g., used by ``CharField``,
|
||||
``FileField``, and ``TextField``), then Django will create
|
||||
an additional index that uses an appropriate `PostgreSQL operator class`_
|
||||
for the column. The extra index is necessary to correctly perfrom
|
||||
lookups that use the ``LIKE`` operator in their SQL, as is done with the
|
||||
``contains`` and ``startswith`` lookup types.
|
||||
|
||||
.. _PostgreSQL operator class: http://www.postgresql.org/docs/8.4/static/indexes-opclass.html
|
||||
|
||||
.. _mysql-notes:
|
||||
|
||||
MySQL notes
|
||||
|
||||
Reference in New Issue
Block a user