• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MySQL : Optimize performance of search on varchar column

 
Saurabh Pillai
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a customer table having column, Name which is varchar(255). In the app we have a search functionality by name. We have about 8 million records in this table. The query is very obvious.



Now this query runs considerably slow and it annoys the users. I was wondering if there is a way to improve the performance of this query.

There is an index on this column but index type is not defined. Options for index type are FULLTEXT, PRIMARY and UNIQUE.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34072
333
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the customer really entering that much of a wildcard? Often, the user is entering the starts with. Which lets you do WHERE customer_name LIKE 'user input customer name%';

This lets you use indexes since the order can be sorted instead of needing to scan the whole table.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic