plpgsql plan cache - Mailing list pgsql-performance

From Joel Jacobson
Subject plpgsql plan cache
Date
Msg-id 38E2265E-B38E-4EBD-BB87-23B46EF4FD1C@gluefinance.com
Whole thread Raw
Responses Re: plpgsql plan cache
List pgsql-performance
Hi,

I am trying to make a select query in my plpgsql function to use an
index allowing an index scan instead of a seq scan.

When running the query in the sql prompt,  it works fine, but
apparently the index is not used for the same query in the plpgsql
function.

The problem is not the data types of the parameters to the function or
the query, they are identical.

When I tried using EXECUTE in the plpgsql function, the index is being
used.

I thought the query planner must have made a bad decision when I
created the function the first time.

I therefore tried to drop the function, disconnect from the sql
client, reconnect (to get a new session), create the function again.
The function still runs slow though.

I cannot understand why the index is not being used when in the
plpgsql function?
I even tried to make a test function containing nothing more than the
single query. Still the index is not being used.
When running the same query in the sql prompt, the index is in use
though.

Is there a way to someone clear the entire query cache or even better
for a particular plpgsql function?

I'm greatful for any ideas.

Best regards,

Joel Jacobson


pgsql-performance by date:

Previous
From: Ron Mayer
Date:
Subject: Re: SSD + RAID
Next
From: "Pierre C"
Date:
Subject: Re: plpgsql plan cache