Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I create an index on these columns?

I have some columns in my database, mostly varchar 255s. They are only accessed once, but they're loaded once per page load/request for logged in users. (Mostly they contain things like the user's preferences).

My question is, should I create indexes on these columns or not? I've already got indexes on other columns which are used in multiple queries as opposed to just read once and stored like these columns.

like image 968
Ali Avatar asked Jan 27 '26 22:01

Ali


1 Answers

You only need indexes on columns that are used for sorting or searching.

ie. they appear in JOIN, WHERE, HAVING, GROUP or ORDER BY clauses.

Even then, it is not strictly necessary.

like image 130
Orbling Avatar answered Jan 29 '26 12:01

Orbling



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!