Hi

While using OR in the query, Mysql doesn't use indexes.. right? Hence takes more time.

If queries have to be ORed on various coloumns (demand of the application) what one 
can do to speed it up.


Table structure:

CREATE TABLE npg_search (
   sno int(11) NOT NULL auto_increment,
   fileid varchar(255) NOT NULL,
   caption text,
   headline varchar(255),
   specialins varchar(255),
   keywords varchar(255) NOT NULL,
   cat varchar(50) NOT NULL,
   byline varchar(255),
   credit varchar(255),
   source varchar(255),
   date date,
   city varchar(100),
   state varchar(100),
   country varchar(100) NOT NULL,
   orgtransref varchar(100),
   copyright varchar(255),
   extratxt text,
   prints tinyint(4),
   extrastr varchar(255),
   bylinetitle varchar(255),
   addedon timestamp(14),
   PRIMARY KEY (sno),
   INDEX (fileid, keywords, cat, country));

As shown columns fileid,keywords,cat and country are indexed (not the composite 
indexed).

Query is:

Select * from table where keywords like '%blah%' or caption like '%blah%' or headline 
like '%blah%'  or cat like '%blah%' limit 20,10


Note: I can not use keywords like 'blah%' it has to be '%blah%' only... (i.e balh can 
be even middle part of the words)

Table contains 50,000 records and queries taking 7 sec which is unbelievable.

Mysql version: 3.23.52

Please suggest me some solution for this.


Thanks in advance

Binay




Reply via email to