pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: xu fei <autofei@yahoo.com>
To: pgsql-hackers@postgresql.org
Subject: full text search index scan query plan changed in 8.4.2?
Date: Sun, 28 Feb 2010 12:42:09 -0800 (PST)
Message-ID: <60218.64374.qm@web45406.mail.sp1.yahoo.com> (raw)

Hi, hackers:

I am testing the index used by full text search recently.

I have install 8.3.9 and 8.4.2 separately. 

In 8.3.9, the query plan is like:

postgres=# explain SELECT s.name as source , t.name as target FROM element as s, element as t WHERE to_tsvector('testcfg',s.name)  @@ to_tsquery('testcfg',replace(t.name,':','|'));                                                                         QUERY PLAN                     ------------------------------------------------------------------------------------------------------------------------------------------------------------ 
Nested Loop  (cost=0.01..259.92 rows=491 width=18)   
 ->  Seq Scan on element t  (cost=0.00..13.01 rows=701 width=9)   
 ->  Index Scan using element_ftsidx_test on element s  (cost=0.01..0.33 rows=1 width=9)         
     Index Cond: (to_tsvector('testcfg'::regconfig, (s.name)::text) @@ to_tsquery('testcfg'::regconfig, replace((t.name)::text, ':'::text, '|'::text)))
(4 rows)

I have index: "element_ftsidx_test" gin (to_tsvector('testcfg'::regconfig, name::text))

The same index and query in 8.4.2: 

postgres=# explain SELECT s.name as source , t.name as target FROM element as s, element as t WHERE to_tsvector('testcfg',s.name)  @@ to_tsquery('testcfg',replace(t.name,':','|')) ;                                                                            QUERY PLAN               ------------------------------------------------------------------------------------------------------------------------------------------------------------------ 
Nested Loop  (cost=0.32..3123.51 rows=2457 width=18)   
 ->  Seq Scan on element t  (cost=0.00..13.01 rows=701 width=9)   
 ->  Bitmap Heap Scan on element s  (cost=0.32..4.36 rows=4 width=9)              Recheck Cond: (to_tsvector('testcfg'::regconfig, (s.name)::text) @@ to_tsquery('testcfg'::regconfig, replace((t.name)::text, ':'::text, '|'::text)))         
        ->  Bitmap Index Scan on element_ftsidx_test  (cost=0.00..0.32 rows=4 width=0)
             Index Cond: (to_tsvector('testcfg'::regconfig, (s.name)::text) @@ to_tsquery('testcfg'::regconfig, replace((t.name)::text, ':'::text, '|'::text)))
(6 rows)

Why the query plans are different and why? Thanks!

Xu Fei


      




view thread (3+ messages)  latest in thread

Message-ID: <60218.64374.qm@web45406.mail.sp1.yahoo.com>
Permalink:  ../60218.64374.qm@web45406.mail.sp1.yahoo.com/
Also on:    postgresql.org/message-id/60218.64374.qm@web45406.mail.sp1.yahoo.com

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: autofei@yahoo.com, pgsql-hackers@postgresql.org
  Subject: Re: full text search index scan query plan changed in 8.4.2?
  In-Reply-To: <60218.64374.qm@web45406.mail.sp1.yahoo.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