Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I index my sort fields in MySQL

I have a field called 'sort_order' and it's bigint, i use it in my mysql queries for sorting.

Is it wise I put an index on it?

like image 256
gio Avatar asked Dec 16 '22 23:12

gio


1 Answers

Generally, yes. If you are doing an ORDER BY on that field, it should probably be indexed. Of course you'll want to test it first to make sure it actually helps - if you only ever select a small number of rows it may not make that much of a difference.

like image 113
Eric Petroelje Avatar answered Jan 07 '23 21:01

Eric Petroelje