Re: Index not used when using a function

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Nick <nboutelier(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Index not used when using a function
Date: 2010-01-14 00:21:38
Message-ID: 11201.1263428498@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Nick <nboutelier(at)gmail(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Nick 2010-01-14 00:28:46 Re: Index not used when using a function
Previous Message Nick 2010-01-13 23:13:20 Index not used when using a function