Re: plan difference between set-returning function with ROWS within IN() and a plain join

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Frank van Vugt <ftm(dot)van(dot)vugt(at)foxi(dot)nl>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: plan difference between set-returning function with ROWS within IN() and a plain join
Date: 2008-05-06 14:17:10
Message-ID: 13551.1210083430@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Frank van Vugt <ftm(dot)van(dot)vugt(at)foxi(dot)nl> writes:
> db=# explain analyse
> select sum(base_total_val)
> from sales_invoice
> where id in (select id from si_credit_tree(80500007));

Did you check whether this query even gives the right answer? The
EXPLAIN output shows that 21703 rows of sales_invoice are being
selected, which is a whole lot different than the other behavior.

I think you forgot the alias foo(id) in the subselect and it's
actually reducing to "where id in (id)", ie, TRUE.

regards, tom lane

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Tom Lane 2008-05-06 14:22:07 Re: Seqscan problem
Previous Message Justin 2008-05-06 13:22:02 Re: need to speed up query