why index all SlugFields ?

11 views
Skip to first unread message

xav4django

unread,
Apr 13, 2007, 7:34:27 AM4/13/07
to django-d...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Hi.

When I use a SlugField in a model,
an index for this field is create in postgres.

Why ?

(config : django 0.96 / postgresql )

A++ Xav.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGH2rD4dg3EDuiPUcRAgmZAJ9qSsRXPZALQ51L0eX67EtAivxl3wCfQARH
/lI6QD8Rxn9MXU5LPfAvxiM=
=+Ssi
-----END PGP SIGNATURE-----

Russell Keith-Magee

unread,
Apr 13, 2007, 7:41:17 AM4/13/07
to django-d...@googlegroups.com
> When I use a SlugField in a model,
> an index for this field is create in postgres.
>
> Why ?

Indexing a fields makes searches over that field faster. Slug fields
are the very definition of a searchable, indexable field - the most
common use case for a Slug is as part of a URL scheme. So, Django
installs an index for each Slug field by default.

Yours,
Russ Magee %-)

Marc Fargas Esteve

unread,
Apr 13, 2007, 7:42:51 AM4/13/07
to django-d...@googlegroups.com
Maybe because there is a high change that you will try to find rows based on this SlugField, so in common cases this INDEX will be nice.

Also it's documented on http://www.djangoproject.com/documentation/model-api/#slugfield that this field has an implicit db_index=True, BUT you can always pass db_index=False if you do not want the index.

Cheers,
Marc

xav4django

unread,
Apr 13, 2007, 8:56:33 AM4/13/07
to django-d...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Thx for your clarification.

Russell Keith-Magee a écrit :


> Indexing a fields makes searches over that field faster. Slug fields
> are the very definition of a searchable, indexable field - the most
> common use case for a Slug is as part of a URL scheme. So, Django
> installs an index for each Slug field by default.

Marc Fargas Esteve a écrit :


> Maybe because there is a high change that you will try to find rows
> based on this SlugField, so in common cases this INDEX will be nice.
> Also it's documented on
> http://www.djangoproject.com/documentation/model-api/#slugfield that
> this field has an implicit db_index=True, BUT you can always pass
> db_index=False if you do not want the index.

-----BEGIN PGP SIGNATURE-----


Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGH34B4dg3EDuiPUcRAhYrAJsFy3fyk2AAhRGd016SGamx7v6TjgCeIM2u
bv9jLPy2XNQgK4JHUG2ARBo=
=VEHH
-----END PGP SIGNATURE-----

Reply all
Reply to author
Forward
0 new messages