Re: Bad plan when join on function

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: <zotov(at)oe-it(dot)ru>,<pgsql-performance(at)postgresql(dot)org>
Subject: Re: Bad plan when join on function
Date: 2011-01-17 20:51:24
Message-ID: 4D34576C02000025000396CB@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Zotov wrote:

> select c.id from OneRow c join abstract a on a.id=AsInteger(c.id)

> Why SeqScan???

Because you don't have an index on AsInteger(c.id).

If your function is IMMUTABLE (each possible combination of input
values always yields the same result), and you declare it such, then
you can index on the function, and it will perform at a speed similar
to the other example.

-Kevin

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Jeremy Palmer 2011-01-17 20:52:18 Re: Possible to improve query plan?
Previous Message Tom Lane 2011-01-17 20:24:26 Re: Possible to improve query plan?