Re: Index not used when using a function

From: Nick <nboutelier(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Index not used when using a function
Date: 2010-01-14 00:28:46
Message-ID: 99b4565d-94cc-4f87-9072-b65beadcdd51@34g2000yqp.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Jan 13, 4:21 pm, t(dot)(dot)(dot)(at)sss(dot)pgh(dot)pa(dot)us (Tom Lane) wrote:
> Nick <nboutel(dot)(dot)(dot)(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
>
> --
> Sent via pgsql-general mailing list (pgsql-gene(dot)(dot)(dot)(at)postgresql(dot)org)
> To make changes to your subscription:http://www.postgresql.org/mailpref/pgsql-general

That was it, thank you.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Yan Cheng Cheok 2010-01-14 00:51:33 Re: Extremely Slow Cascade Delete Operation
Previous Message Tom Lane 2010-01-14 00:21:38 Re: Index not used when using a function