Re: Pruning useless tables for queries

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Pruning useless tables for queries
Date: 2003-05-21 16:42:35
Message-ID: 7794.1053535355@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Martijn van Oosterhout <kleptog(at)svana(dot)org> writes:
> One optimisation is for the query planner to drop tables whose output do not
> affect the final result (where the WHERE clauses and the CHECK constraints
> prove that no rows can be returned). While this is not the case for simple
> queries, when involving views and inheritance it's very easy to do.

Under what conditions is this actually going to buy you anything?

Indexscans with self-contradictory index conditions, for example, fall
through quite quickly already (look at the scan startup logic in nbtree.c).
I'm not sure that there's any gain in having the planner duplicate that
effort.

> Ideally, you could create a new node would has a RangeTable (I think that's
> the right term) but produces no output.

We already use Result nodes with resconstantqual qualifiers to handle
gating of execution of entire subplans (see query_planner()). It might
be worth thinking about whether that concept is useful to apply at lower
levels of a plan tree.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2003-05-21 17:40:02 Re: Heads up: 7.3.3 this Wednesday
Previous Message wade 2003-05-21 16:14:40 CVS Servers (Anonymous)