Skip site navigation (1) Skip section navigation (2)

Re: plpgsql functions and the planner

From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: "Matthew Dennis" <mdennis(at)merfer(dot)net>
Cc: "PGSQL" <pgsql-general(at)postgresql(dot)org>
Subject: Re: plpgsql functions and the planner
Date: 2008-04-27 14:30:40
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-general
"Matthew Dennis" <mdennis(at)merfer(dot)net> writes:

> Do SQL statements inside of plpgsql functions get planned upon every
> execution, only when the function is first executed/defined, or something
> else entirely?

First executed per session.

> Now, when bar is executed again, will PG (8.3.1) know that a seqscan is no
> longer reasonable?

It won't notice until someone runs ANALYZE on that table. autovacuum should
notice that it's necessary and run but might not run promptly enough for your
purposes. You might have to run analyze within your function.

Before 8.3 it still wouldn't get replanned until you started a new session but
8.3 is more clever.

  Gregory Stark
  Ask me about EnterpriseDB's 24x7 Postgres support!

In response to

pgsql-general by date

Next:From: Martijn van OosterhoutDate: 2008-04-27 14:32:44
Subject: Re: taking actions on rollback (PHP)
Previous:From: Douglas McNaughtDate: 2008-04-27 13:45:54
Subject: Re: plpgsql functions and the planner

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group