pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oleg Bartunov <oleg@sai.msu.su>
To: Kris Kiger <kris@musicrebellion.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: tsearch2 poor performance
Date: Fri, 24 Sep 2004 21:20:36 +0400 (MSD)
Message-ID: <Pine.GSO.4.58.0409242114270.14980@ra.sai.msu.su> (raw)
In-Reply-To: <4154542F.3000909@musicrebellion.com>
References: <4154542F.3000909@musicrebellion.com>

Kris,

could you post 'explain analyze' output ?
Also, could you disable index usage (set enable_indexscan=off)
and rerun search using tsearch2 ?

also, could you run 'stat' function to see frequency distribution
of words. See http://www.sai.msu.su/~megera/oddmuse/index.cgi/Tsearch_V2_Notes
for details.

Oleg
On Fri, 24 Sep 2004, Kris Kiger wrote:

> Hi all.  I am doing some work with tsearch2 and am not sure what to
> expect out of it, performance wise.  Here is my setup:
>
>                           Table "public.product"
>    Column    |   Type   |                    Modifiers
> -------------+----------+-------------------------------------------------
>  description | text     |
>  product_id  | integer  | default nextval('product_product_id_seq'::text)
>  vector      | tsvector |
> Indexes:
>     "vector_idx" gist (vector)
> Triggers:
>     tsvectorupdate BEFORE INSERT OR UPDATE ON product FOR EACH ROW EXECUTE PROCEDURE tsearch2('vector', 'description')
>
> This table has 3,000,000 rows in it.  Each description field has roughly 50 characters.  There are fewer than ten thousand distinct words in my 3,000,000 rows.  The vector was filled using the description fields values.  I ran a vacuum full analyze before executing any of my queries.
>
> Here are a couple of tests I performed using the tsearch index and like;
>
> search_test=# select count(*) from product where vector @@ to_tsquery('oil');
>  count
> --------
>  226357
> (1 row)
>
> Time: 191056.230 ms
>
> search_test=# select count(*) from product where vector @@ to_tsquery('hydrogen');
>  count
> --------
>  226868
> (1 row)
>
> Time: 306411.957 ms
>
> search_test=# select count(*) from product where description like '% oil %';
>  count
> --------
>  226357
> (1 row)
>
> Time: 38426.851 ms
>
> search_test=# select count(*) from product where description like '% hydrogen %';
>  count
> --------
>  226868
> (1 row)
>
> Time: 38265.421 ms
>
>
> Both of the likes are using a sequential scan and both of the tsearch queries use the gist index.  Did I miss a configuration parameter, are these queries incorrectly using tsearch2,or is this tsearch2's average performance?  Thanks in advance for the input!
>
> Kris
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
>                http://www.postgresql.org/docs/faqs/FAQ.html
>

	Regards,
		Oleg
_____________________________________________________________
Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
Sternberg Astronomical Institute, Moscow University (Russia)
Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/
phone: +007(095)939-16-83, +007(095)939-23-83



view thread (18+ messages)  latest in thread

Message-ID: <Pine.GSO.4.58.0409242114270.14980@ra.sai.msu.su>
Permalink:  ../Pine.GSO.4.58.0409242114270.14980@ra.sai.msu.su/
Also on:    postgresql.org/message-id/Pine.GSO.4.58.0409242114270.14980@ra.sai.msu.su

 · 

reply

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: oleg@sai.msu.su, kris@musicrebellion.com
  Subject: Re: tsearch2 poor performance
  In-Reply-To: <Pine.GSO.4.58.0409242114270.14980@ra.sai.msu.su>
  References: <4154542F.3000909@musicrebellion.com> <Pine.GSO.4.58.0409242114270.14980@ra.sai.msu.su>

* 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