Indexing for search fields
Indexing is a great feature of MySQL database; it can be used wisely, and it is also a best practice to use it for regex filtering through where clauses for those frequently used columns. If indexing is not there, then it would result in a full table scan, which would deteriorate performance as the table grows, resulting in bad schema design. It would use little more disk space than without an index, but it's worth it for desired performance.
For example, consider a user's table that has the userId, firstName, and lastName columns, among which none of them have indexes. If a read query for filtering based on firstName, along with a regex or like pattern in the WHERE clause would definitely have to go through the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access