Interesting optimizer's supposition in 8.1

From: Teodor Sigaev <teodor(at)sigaev(dot)ru>
To: Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Interesting optimizer's supposition in 8.1
Date: 2005-10-05 14:32:59
Message-ID: 4343E41B.1090405@sigaev.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tsearch2 has function to_tsquery defined as:
CREATE FUNCTION to_tsquery(oid, text)
RETURNS tsquery
AS '$libdir/tsearch2'
LANGUAGE 'c' with (isstrict,iscachable);

And let we take 2 essential equivalent queries:

# explain select book.id from to_tsquery('foo') as t, book where book.fts @@ t;
QUERY PLAN
--------------------------------------------------------------------
Nested Loop (cost=13.19..6550.69 rows=290 width=4)
Join Filter: ("inner".fts @@ "outer".t)
-> Function Scan on t (cost=0.00..12.50 rows=1000 width=32)
-> Materialize (cost=13.19..16.09 rows=290 width=36)
-> Seq Scan on book (cost=0.00..12.90 rows=290 width=36)
# explain select book.id from book where book.fts @@ to_tsquery('foo');
QUERY PLAN
-----------------------------------------------------
Seq Scan on book (cost=0.00..13.62 rows=1 width=4)
Filter: (fts @@ '''foo'''::tsquery)

Why planner suppose that t 'table' will return 1000 rows? Obviosly that function
returns only one value because of itsn't marked as 'returns setof'.

--
Teodor Sigaev E-mail: teodor(at)sigaev(dot)ru
WWW: http://www.sigaev.ru/

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2005-10-05 15:08:27 Re: Fix for file names with spaces
Previous Message Devrim GUNDUZ 2005-10-05 14:32:40 Re: Slony RPM issue