pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Backup/restore of pg_statistics
2+ messages / 2 participants
[nested] [flat]

* Backup/restore of pg_statistics
@ 2003-11-17 14:51  Joel Jacobson <joel@jacobson.be>
  0 siblings, 1 reply; 2+ messages in thread

From: Joel Jacobson @ 2003-11-17 14:51 UTC (permalink / raw)
  To: pgsql-performance

Hi,

I understand that it is not possible to occasionally re-plan the queries in a
PL/pgSQL function without dropping and re-creating the function.

I think it would be useful if the queries in a PL/pgSQL function could be
re-planned on-the-fly.

When a lot of data has been added/modified and ANALYZE is suitable to run, it
would also be a great idea to re-plan the queries used in PL/pgSQL functions.
I understand that this is not possible?
The only way would be to DROP/CREATE the functions or to use EXECUTE.
I don't think EXECUTE is an option, because preparing the queries every time the
function is called is in my case not necessary and just a waste of
performance.

As a work-around, I am forced to,
1. populate the database with a lot of test data,
2. run ANALYZE,
3. and finally, create the PL/pgSQL functions
The prepared queries in the functions will now be sufficiently optimized.

I don't think this is a nice solution.

I also thought of a slightly better solution, but I don't know if it is
possible.
My idea was to populate the database once and then save the data in
pg_statistics generated by ANALYZE to a file. Every time the database needs to
be created, the statistics could then be restored thus making the planner
produce "future-optimized" queries when the PL/pgSQL functions are created,
even though the database is empty.

I would greatly appreciate any help/comments.

Thank you.

Joel Jacobson <joel@jacobson.be>



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Backup/restore of pg_statistics
@ 2003-11-20 04:39  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Joel Jacobson <joel@jacobson.be>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2003-11-20 04:39 UTC (permalink / raw)
  To: Joel Jacobson <joel@jacobson.be>; +Cc: pgsql-performance

Joel Jacobson <joel@jacobson.be> writes:
> I understand that it is not possible to occasionally re-plan the queries in a
> PL/pgSQL function without dropping and re-creating the function.

Huh?  You only need to start a fresh connection.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2003-11-20 04:39 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-11-17 14:51 Backup/restore of pg_statistics Joel Jacobson <joel@jacobson.be>
2003-11-20 04:39 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox