Sourav Prem
Sourav Prem

Reputation: 1063

Will adding db.index=True to a Field in my Django Model help if there is no index on that field in the original db

I am reading this documentation and it says you should add indexes to fields that you frequently query using filter(), exclude(), order_by().

I agree with the statement, but will this addition really help if there is no index on the actual database?

Upvotes: 0

Views: 349

Answers (1)

Chris
Chris

Reputation: 137215

Adding db_index = True to a field and then running makemigrations will generate a migration that adds an appropriate index to your database when applied.

Upvotes: 3

Related Questions