jQuery in Action, 2nd edition*
The moose likes JDBC and the fly likes MySQL : Optimize performance of search on varchar column Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "MySQL : Optimize performance of search on varchar column" Watch "MySQL : Optimize performance of search on varchar column" New topic
Author

MySQL : Optimize performance of search on varchar column

Saurabh Pillai
Ranch Hand

Joined: Sep 12, 2008
Posts: 498
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 29219
    
134

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: MySQL : Optimize performance of search on varchar column
 
Similar Threads
Enabling non-programmers to change the output of my code ?
SQL Query for this?
Creating Indexes on Number Columns
Key comparison
Joining tables