If you have come to Django with a fairly good MySQL, PostgreSQL background this will be obvious. If your experience of databases is creating a Django model, this may be of use to you.
Here is an example model
You might be thinking, what’s wrong?
Well now lets assume you have 2000 entries in your database and you decied you want to list your items in order they were added, or by title. Databases are great, but without indexes it needs to scan over 2000 rows to figure out the order.
Heres the better version of the same model
So, whats better?
Well, now there are indexes, your database server just needs to take a look over the list of indexes. Its a lot faster.
When to use indexes
A good rule, if you are going to order by, or filter by, it should be indexed.