One-Shot Plans

From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: One-Shot Plans
Date: 2011-06-14 18:25:13
Message-ID: BANLkTikAN=g1oCC+tY72o7FFH0OjF+Yy=A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Currently, the planner and executor are mostly independent of each
other: the planner doesn't really know when the plan will be executed,
and the executor doesn't know how recently the plan was made.

We can work out the various paths through the traffic cop to see when
a plan will be a "one-shot" - planned and then executed immediately,
then discarded.

In those cases we can take advantage of better optimisations. Most
interestingly, we can evaluate stable functions at plan time, to allow
us to handle partitioning and partial indexes better.

Patch attached. Works...

SET constraint_exclusion = on;
ALTER TABLE <table> ADD CHECK (dt < current_date - 5);
SELECT * FROM <table> WHERE datecolumn >= current_date - 1;
QUERY PLAN
------------------------------------------
Result (cost=0.00..0.01 rows=1 width=0)
One-Time Filter: false
(2 rows)

WIP in the sense that we might want to change the special case
parameter handling as well.

Comments?

--
 Simon Riggs                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

Attachment Content-Type Size
oneshot_plans.v2.patch application/octet-stream 8.7 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2011-06-14 18:28:03 Re: One-Shot Plans
Previous Message Kevin Grittner 2011-06-14 18:20:38 Re: procpid?