Re: Index not used when using a function - Mailing list pgsql-general

From Tom Lane
Subject Re: Index not used when using a function
Date
Msg-id 11201.1263428498@sss.pgh.pa.us
Whole thread Raw
In response to Index not used when using a function  (Nick <nboutelier@gmail.com>)
List pgsql-general
Nick <nboutelier@gmail.com> writes:
> SELECT * FROM locations WHERE id = 12345 LIMIT 1
> uses the primary key (id) index, but...

> SELECT * FROM locations WHERE id = get_location_id_from_ip(641923892)
> LIMIT 1

> does not and is verrry slow. Any ideas why?

You didn't mark the function stable or immutable.
http://www.postgresql.org/docs/8.4/static/xfunc-volatility.html

            regards, tom lane

pgsql-general by date:

Previous
From: akuster
Date:
Subject: Re: How to subscribe to your security list?
Next
From: Nick
Date:
Subject: Re: Index not used when using a function