How to use Logical Operators in Fulltext Search?

Started by Gaini Rajeshwarover 16 years ago4 messagesgeneral
Jump to latest
#1Gaini Rajeshwar
raja.rajeshwar2006@gmail.com

Hi All,

I am doing a fulltext search something like this:

SELECT doc_id FROM docs WHERE tsv_title($$'magnetic induction'$$) OR
tsv_body($$'magnetic induction'$$) OR tsv_abstract($$'abstract'$$)

It is taking approximately 100 secs to execute.

But running the query on individual column something like below is taking
just few milliseconds

1) SELECT doc_id FROM docs WHERE tsv_title($$'magnetic induction'$$)

2) SELECT doc_id FROM docs WHERE tsv_body($$'magnetic induction'$$)

3) SELECT doc_id FROM docs WHERE tsv_abstract($$'magnetic induction'$$)

All the above queries are taking just few milliseconds, whereas the bigining
one taking around 100 secs.

Does anyone know, what could be wrong in this? Is this not the way to
specify logical operators like *AND, OR, NOT ?*

#2Sam Jas
samjas33@yahoo.com
In reply to: Gaini Rajeshwar (#1)
Re: How to use Logical Operators in Fulltext Search?

Can we have a explain plan SELECT doc_id FROM docs WHERE tsv_title($$'magnetic induction'$$) OR
tsv_body($$'magnetic induction'$$) OR tsv_abstract($$'abstract'$$)

--
Thanks
Sam

--- On Wed, 21/10/09, Gaini Rajeshwar <raja.rajeshwar2006@gmail.com> wrote:

From: Gaini Rajeshwar <raja.rajeshwar2006@gmail.com>
Subject: [GENERAL] How to use Logical Operators in Fulltext Search?
To: "pgsql-general@postgresql.org mailing list" <pgsql-general@postgresql.org>
Date: Wednesday, 21 October, 2009, 1:12 PM

Hi All,
 
I am doing a fulltext search something like this:
 
SELECT doc_id FROM docs WHERE tsv_title($$'magnetic induction'$$) OR tsv_body($$'magnetic induction'$$) OR tsv_abstract($$'abstract'$$)
 
It is taking approximately 100 secs to execute.
 
But running the query on individual column something like below is taking just few milliseconds
 
1) SELECT doc_id FROM docs WHERE tsv_title($$'magnetic induction'$$) 
 
2) SELECT doc_id FROM docs WHERE tsv_body($$'magnetic induction'$$)
 
3) SELECT doc_id FROM docs WHERE tsv_abstract($$'magnetic induction'$$)
 
 
All the above queries are taking just few milliseconds, whereas the bigining one taking around 100 secs.
 
Does anyone know, what could be wrong in this? Is this not the way to specify logical operators like AND, OR, NOT ?
 

Try the new Yahoo! India Homepage. Click here. http://in.yahoo.com/trynew

#3Sam Jas
samjas33@yahoo.com
In reply to: Gaini Rajeshwar (#1)
Re: How to use Logical Operators in Fulltext Search?

Also OR operator taking time.

--- On Wed, 21/10/09, Gaini Rajeshwar <raja.rajeshwar2006@gmail.com> wrote:

From: Gaini Rajeshwar <raja.rajeshwar2006@gmail.com>
Subject: [GENERAL] How to use Logical Operators in Fulltext Search?
To: "pgsql-general@postgresql.org mailing list" <pgsql-general@postgresql.org>
Date: Wednesday, 21 October, 2009, 1:12 PM

Hi All,
 
I am doing a fulltext search something like this:
 
SELECT doc_id FROM docs WHERE tsv_title($$'magnetic induction'$$) OR tsv_body($$'magnetic induction'$$) OR tsv_abstract($$'abstract'$$)
 
It is taking approximately 100 secs to execute.
 
But running the query on individual column something like below is taking just few milliseconds
 
1) SELECT doc_id FROM docs WHERE tsv_title($$'magnetic induction'$$) 
 
2) SELECT doc_id FROM docs WHERE tsv_body($$'magnetic induction'$$)
 
3) SELECT doc_id FROM docs WHERE tsv_abstract($$'magnetic induction'$$)
 
 
All the above queries are taking just few milliseconds, whereas the bigining one taking around 100 secs.
 
Does anyone know, what could be wrong in this? Is this not the way to specify logical operators like AND, OR, NOT ?
 

Keep up with people you care about with Yahoo! India Mail. Learn how. http://in.overview.mail.yahoo.com/connectmore

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Gaini Rajeshwar (#1)
Re: How to use Logical Operators in Fulltext Search?

Gaini Rajeshwar <raja.rajeshwar2006@gmail.com> writes:

I am doing a fulltext search something like this:

SELECT doc_id FROM docs WHERE tsv_title($$'magnetic induction'$$) OR
tsv_body($$'magnetic induction'$$) OR tsv_abstract($$'abstract'$$)

Since you haven't told us what those functions do, we're just guessing.
But I would suggest that if you can use | within a single tsquery,
it'll probably run faster.

regards, tom lane