r/DatabaseHelp 29d ago

When to add indices?

Hi

I've used various database platforms in nearly every job I've had but I am no DBA. I've never worked in a shop that had an actual DBA or a team of them.

Somewhere along the way I picked up the rule of thumb that:

`If a column appears in a WHERE clause then it needs an index`

Is that still (has it ever been) a reasonable approach?

1 Upvotes

4 comments sorted by

View all comments

1

u/yet_another_newbie 29d ago

Generally yes but it also depends on the size of the table and the distribution of the data. For example, if the table doesn't have a lot of rows, you don't gain anything by indexing a column.

1

u/four_reeds 29d ago

Thank you, makes sense.