• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

MySQL : Optimize performance of search on varchar column

 
Ranch Hand
Posts: 541
  • 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.
 
author & internet detective
Posts: 39341
755
Eclipse IDE VI Editor Java
  • 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
Boost this thread!