Re: Bad plan when join on function - Mailing list pgsql-performance

From Kevin Grittner
Subject Re: Bad plan when join on function
Date
Msg-id 4D34576C02000025000396CB@gw.wicourts.gov
Whole thread Raw
In response to Bad plan when join on function  (Zotov <zotov@oe-it.ru>)
Responses Re: Bad plan when join on function  (Pavel Stehule <pavel.stehule@gmail.com>)
List 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

pgsql-performance by date:

Previous
From: Tom Lane
Date:
Subject: Re: Possible to improve query plan?
Next
From: Jeremy Palmer
Date:
Subject: Re: Possible to improve query plan?