Re: When is a good time to use db_index? Rule of thumb?

2011-09-16 Thread Andre Terra
Wow, great question and even better answers! Amazing help indeed. Thanks everyone, I learned a bunch from this too. Enjoy the weekend! Cheers, AT On Fri, Sep 16, 2011 at 1:52 PM, Micky Hulse wrote: > Thank you Micah, Donald and Doug! I really appreciate the help! :) > > That really helps to c

Re: When is a good time to use db_index? Rule of thumb?

2011-09-16 Thread Micky Hulse
Thank you Micah, Donald and Doug! I really appreciate the help! :) That really helps to clear things up for me. Have a great weekend. Cheers, Micky -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us

Re: When is a good time to use db_index? Rule of thumb?

2011-09-15 Thread Doug Ballance
Another clarification: It tells django to create an index on that field when you run syncdb to create the tables for your apps. Adding it to an existing model won't change anything by itself. If you decide a field needs an index you can add it to the model definition, and then you can use the "m

Re: When is a good time to use db_index? Rule of thumb?

2011-09-15 Thread Donald Stufft
To expand, a better answer is when you have profiled your application and have shown a bottleneck, and have tested it with an index on that column and seen an improvement. db_index isn't free, it incurs a penalty on writes so you need to be careful when using them. On Friday, September 16,

Re: When is a good time to use db_index? Rule of thumb?

2011-09-15 Thread Micah Carrick
As an oversimplification.. any time you will be looking up a record based on a field, then you want an index on that (or those) fields. If you're finding a row based on a slug, you want to index that slug field. A good tool is to use the Django debug toolbar. When you load a page you can take a lo

When is a good time to use db_index? Rule of thumb?

2011-09-15 Thread Micky Hulse
Hello, I have been using this great category/tag model: https://github.com/praekelt/django-category/blob/master/category/models.py ... and I noticed that the author added a db_index on the SlugField of the Category model. I hate to admit it, but I don't think I have ever explicitly used db_inde