From: | George Essig <george_essig(at)yahoo(dot)com> |
---|---|
To: | Kris Kiger <kris(at)musicrebellion(dot)com> |
Cc: | pgsql-admin(at)postgresql(dot)org |
Subject: | Re: tsearch2 poor performance |
Date: | 2004-09-28 13:48:03 |
Message-ID: | 20040928134803.88842.qmail@web53705.mail.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
Kris Kiger wrote:
> search_test=# explain analyze SELECT count(q) FROM product,
> to_tsquery('oil') AS q WHERE vector @@ q;
> QUERY PLAN
>
---------------------------------------------------------------------------------------------------------------------------------
> Aggregate (cost=67847264.50..67847264.50 rows=1 width=32) (actual
> time=83311.552..83311.555 rows=1 loops=1)
> -> Nested Loop (cost=12.50..67839764.50 rows=3000001 width=32)
> (actual time=0.204..81960.198 rows=226357 loops=1)
> Join Filter: ("outer".vector @@ "inner".q)
> -> Seq Scan on product (cost=0.00..339752.00 rows=3000000
> width=32) (actual time=0.100..27415.795 rows=3000000 loops=1)
> -> Materialize (cost=12.50..22.50 rows=1000 width=32) (actual
> time=0.003..0.006 rows=1 loops=3000000)
> -> Function Scan on q (cost=0.00..12.50 rows=1000
> width=32) (actual time=0.020..0.024 rows=1 loops=1)
> Total runtime: 83311.735 ms
> (7 rows)
The explain analyze output doesn't show that a gist index on the vector column is being used.
This is because either you don't have an index defined and\or the query is causing a poor plan to
be chosen. I've found that putting to_tsquery in the FROM clause does not execute fast.
Try rewriting the query as:
explain analyze SELECT count(to_tsquery('oil')) FROM product WHERE vector @@ to_tsquery('oil');
or
explain analyze SELECT count(*) FROM product WHERE vector @@ to_tsquery('oil');
George Essig
From | Date | Subject | |
---|---|---|---|
Next Message | CHRIS HOOVER | 2004-09-28 14:24:00 | Help determining values for max_fsm_pages, max_fsm_relations |
Previous Message | Thomas Madsen | 2004-09-28 13:12:25 | Vacuum full - disk space eaten by WAL logfiles |