unexpected plan for unused table (8.1dev)

From: Oleg Bartunov <oleg(at)sai(dot)msu(dot)su>
To: Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: unexpected plan for unused table (8.1dev)
Date: 2005-08-29 05:50:15
Message-ID: Pine.GSO.4.63.0508290945250.16397@ra.sai.msu.su
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi there,

I'm a bit surprised how bad could be plan for unused table.
I had to cancel second query :)

tp=# explain analyze select tp_rewrite_substitute(query,
'select p.name_tsquery, p.name_alias_tsquery from place p')
from to_tsquery('new&york&hotel') as query;
y;
QUERY PLAN
---------------------------------------------------------------------------------------------------------------
Function Scan on query (cost=0.00..15.00 rows=1000 width=32) (actual time=3801.069..3801.071 rows=1 loops=1)
Total runtime: 3801.107 ms
(2 rows)

tp=# explain analyze select tp_rewrite_substitute(query,
'select p.name_tsquery, p.name_alias_tsquery from place p')
from place, to_tsquery('new&york&hotel') as query;
^^^^^

Here is plan without analyze:

tp=# explain select tp_rewrite_substitute(query,
'select p.name_tsquery, p.name_alias_tsquery from place p')
from place, to_tsquery('new&york&hotel') as query;
QUERY PLAN
---------------------------------------------------------------------------
Nested Loop (cost=13.50..44280620.90 rows=1964340000 width=32)
-> Seq Scan on place (cost=0.00..82957.40 rows=1964340 width=0)
-> Materialize (cost=13.50..23.50 rows=1000 width=32)
-> Function Scan on query (cost=0.00..12.50 rows=1000 width=32)
(4 rows)

The only difference is unused table 'place' in FROM-clause. I typed in by
mistake, but I think optimizer could figure out not to take into account
this table.

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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Hannu Krosing 2005-08-29 06:37:11 Re: unexpected plan for unused table (8.1dev)
Previous Message Tom Lane 2005-08-29 04:33:59 Re: [HACKERS] Improved \df(+) in psql + backward-compatibility