If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > How to create increase search performance using fulltext index?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-01-11, 05:32
vibhavram vibhavram is offline
Registered User
 
Join Date: May 2010
Location: Hyderabd
Posts: 12
How to create increase search performance using fulltext index?

I have got a table with 2 columns on which I would like to perform a text search. The table details are as follows.

here is the show create table

CREATE TABLE `dc_titles` (
`titleid` bigint(20) NOT NULL AUTO_INCREMENT,
`titletext` varchar(128) NOT NULL,
PRIMARY KEY (`titleid`),
FULLTEXT KEY `titletext` (`titletext`)
) ENGINE=MyISAM AUTO_INCREMENT=610 DEFAULT CHARSET=latin1

Now I would like to perform a text search on this table for finding relevant titles for a string. for example I want to find relevant titletext for the term "Best computer shops".

I used a query

SELECT *, MATCH(titletext) AGAINST('Best computer shops') AS score WHERE score > 1 ORDER BY score LIMIT 0,20;

This is working well if the total number of records in the table is less than 50000 records. When it is crossing 50000 records it is loading server heavily.

Is this the correct way of using query or is there more better way to improve search performance?
Reply With Quote
  #2 (permalink)  
Old 10-01-11, 07:37
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
that query couldn't possibly have worked

first of all, you cannot assign a column alias in the SELECT clause and then use that alias in the WHERE clause

more importantly, however, you're missing your FROM clause

please do a SHOW CREATE TABLE so we can see what indexes the table has
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 10-02-11, 11:22
vibhavram vibhavram is offline
Registered User
 
Join Date: May 2010
Location: Hyderabd
Posts: 12
Quote:
Originally Posted by r937 View Post
that query couldn't possibly have worked

first of all, you cannot assign a column alias in the SELECT clause and then use that alias in the WHERE clause

more importantly, however, you're missing your FROM clause

please do a SHOW CREATE TABLE so we can see what indexes the table has
Here is the show table

CREATE TABLE `dc_titles` (
`titleid` bigint(20) NOT NULL AUTO_INCREMENT,
`titletext` varchar(128) NOT NULL,
PRIMARY KEY (`titleid`),
FULLTEXT KEY `titletext` (`titletext`)
) ENGINE=MyISAM AUTO_INCREMENT=610 DEFAULT CHARSET=latin1

Now the exact query what I am using is

SELECT *, MATCH(titletext) AGAINST('Best computer shops') AS score FROM dc_titles WHERE (MATCH(titletext) AGAINST('Best computer shops')) > 1 ORDER BY score DESC LIMIT 0,20;
Reply With Quote
  #4 (permalink)  
Old 10-02-11, 11:48
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
that looks fine, thanks
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 10-02-11, 12:25
vibhavram vibhavram is offline
Registered User
 
Join Date: May 2010
Location: Hyderabd
Posts: 12
Quote:
Originally Posted by r937 View Post
that looks fine, thanks
Is there any other way to make my search more faster? This query is loading my server heavily after reaching 50000 records.
Reply With Quote
  #6 (permalink)  
Old 10-02-11, 13:05
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
sorry, i have no idea
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Tags
fulltext index, search

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On