Index not used when using a function

From: Nick <nboutelier(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Index not used when using a function
Date: 2010-01-13 23:13:20
Message-ID: 45d619f5-7dec-416d-90d8-04849b10367f@a6g2000yqm.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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? Whats weird is that it
works (uses index) on a previous db, but when I copied everything over
to a new db it doesnt. Ive ran vacuum + analyze, does the planner just
need more time to figure out that it needs to use an index?

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2010-01-14 00:21:38 Re: Index not used when using a function
Previous Message Jaime Casanova 2010-01-13 22:38:49 Re: postgres