Query planner gaining the ability to replanning after start of query execution.

From: Oliver Mattos <omattos(at)gmail(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: Query planner gaining the ability to replanning after start of query execution.
Date: 2017-11-13 16:44:49
Message-ID: CAER07O05V+3Sut=--F0Cagve81Rj7dm4fDdsUoS7NiuS+sU4hw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

I am interested in giving the query planner the ability to replan (or
re-rank plans) after query execution has begun, based on the
progression of the query so far.

Example use case:

* A LIMIT 1 query is planned using an expensive scan which the
planner expects to return a large number of results, and to terminate
early. The reality is the query actually produces no results, and
the scan must run to completion, potentially taking thousands of times
longer than expected.

* If this plans costs were adjusted mid-execution to reflect the fact
that the scan is producing far fewer rows than expected, then another
query plan might come out ahead, which would complete far faster.

Has this been done before? Are there any pitfalls to beware of?

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Arne Roland 2017-11-13 20:06:20 Re: Query planner gaining the ability to replanning after start of query execution.
Previous Message Pavel Stehule 2017-11-13 12:30:58 Re: proposal: schema variables