From: Kris Kiger <kris@musicrebellion.com>
To: pgsql-admin@postgresql.org
Subject: Re: tsearch2 poor performance
Date: Fri, 01 Oct 2004 17:01:48 -0500
Message-ID: <415DD3CC.3030208@musicrebellion.com> (raw)
References: <71E37EF6B7DCC1499CEA0316A2568328DC9DF0@loki.wc.globexplorer.net>
<4158409E.8060109@musicrebellion.com>
<Pine.GSO.4.58.0409272040090.14980@ra.sai.msu.su>
<41584E49.5040301@musicrebellion.com>
<Pine.GSO.4.58.0409272243140.14980@ra.sai.msu.su>
<41586264.5020302@musicrebellion.com>
Hey all, its me again. If I do not do a count(product_id) on my
tsearch2 queries, its actually really fast, for example;
explain analyze SELECT product_id FROM product, to_tsquery('bear') AS q
WHERE vector @@ q LIMIT 1000;
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------
Limit (cost=0.00..2081.60 rows=1000 width=4) (actual
time=2.308..51.522 rows=1000 loops=1)
-> Nested Loop (cost=0.00..6244798.55 rows=3000001 width=4) (actual
time=2.299..45.637 rows=1000 loops=1)
-> Function Scan on q (cost=0.00..12.50 rows=1000 width=32)
(actual time=0.023..0.023 rows=1 loops=1)
-> Index Scan using vector_idx on product (cost=0.00..6207.29
rows=3000 width=36) (actual time=2.253..37.946 rows=1000 loops=1)
Index Cond: (product.vector @@ "outer".q)
Filter: (product.vector @@ "outer".q)
Total runtime: 122.487 ms
explain analyze SELECT product_id FROM product, to_tsquery('complex') AS
q WHERE vector @@ q LIMIT 1000;
QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------
Limit (cost=0.00..2081.60 rows=1000 width=4) (actual
time=4.943..2325.949 rows=1000 loops=1)
-> Nested Loop (cost=0.00..6244798.55 rows=3000001 width=4) (actual
time=4.933..2319.885 rows=1000 loops=1)
-> Function Scan on q (cost=0.00..12.50 rows=1000 width=32)
(actual time=0.040..0.040 rows=1 loops=1)
-> Index Scan using vector_idx on product (cost=0.00..6207.29
rows=3000 width=36) (actual time=4.868..2311.087 rows=1000 loops=1)
Index Cond: (product.vector @@ "outer".q)
Filter: (product.vector @@ "outer".q)
Total runtime: 2329.389 ms
From what I know, there is only one reason I can offer why a count
takes approximately 30~40 seconds longer on these same queries... that
is that count has to evaluate whether a value is null or not. There
probably is a better reason, if anyone has any ideas, I would much
appreciate you sharing! Also, why the big difference in query times in
the above?
bear appears 780963 times in 696668 documents
complex appears 468669 times in 440339 documents.
Again, thanks all!
Kris
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: kris@musicrebellion.com
Subject: Re: tsearch2 poor performance
In-Reply-To: <415DD3CC.3030208@musicrebellion.com>
References: <71E37EF6B7DCC1499CEA0316A2568328DC9DF0@loki.wc.globexplorer.net> <4158409E.8060109@musicrebellion.com> <Pine.GSO.4.58.0409272040090.14980@ra.sai.msu.su> <41584E49.5040301@musicrebellion.com> <Pine.GSO.4.58.0409272243140.14980@ra.sai.msu.su> <41586264.5020302@musicrebellion.com> <415DD3CC.3030208@musicrebellion.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox