pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Adaptive query execution
3+ messages / 2 participants
[nested] [flat]

* Adaptive query execution
@ 2014-05-13 20:08 Tim Kane <tim.kane@gmail.com>
  2014-05-13 20:13 ` Re: Adaptive query execution Claudio Freire <klaussfreire@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Tim Kane @ 2014-05-13 20:08 UTC (permalink / raw)
  To: pgsql-performance


Hi all,

So I was thinking about the following, after experimenting with constraint
exclusion.

I thought I would see what happens when I do this:

  SELECT * FROM ONLY table_a UNION SELECT * FROM table_b;


I noticed that despite table_a still having no data in it, the planner has
already decided that it needs to insert a chain of  ‘append->sort->unique’
nodes into the plan.

That’s fairly reasonable.
While I understand that we can’t readily know about wether a given node will
return anything or not - would it be possible to have the execution engine
branch off in the event that a given node returns nothing at all?

I guess there are probably a lot of considerations, and I suspect it would
considerably increase planning time, though maybe it also presents an
opportunity for some interesting approaches to adaptive query execution.

I don’t know so much about this, though I’m sure there are all kinds of
research papers discussing it.
Is this something that has been considered before?

Tim

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

* Re: Adaptive query execution
  2014-05-13 20:08 Adaptive query execution Tim Kane <tim.kane@gmail.com>
@ 2014-05-13 20:13 ` Claudio Freire <klaussfreire@gmail.com>
  2014-05-13 20:33   ` Re: Adaptive query execution Tim Kane <tim.kane@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Claudio Freire @ 2014-05-13 20:13 UTC (permalink / raw)
  To: Tim Kane <tim.kane@gmail.com>; +Cc: pgsql-performance

On Tue, May 13, 2014 at 5:08 PM, Tim Kane <tim.kane@gmail.com> wrote:
> Hi all,
>
> So I was thinking about the following, after experimenting with constraint
> exclusion.
>
> I thought I would see what happens when I do this:
>
>   SELECT * FROM ONLY table_a UNION SELECT * FROM table_b;
>
>
> I noticed that despite table_a still having no data in it, the planner has
> already decided that it needs to insert a chain of  ‘append->sort->unique’
> nodes into the plan.
>
> That’s fairly reasonable.
> While I understand that we can’t readily know about wether a given node will
> return anything or not - would it be possible to have the execution engine
> branch off in the event that a given node returns nothing at all?
>
> I guess there are probably a lot of considerations, and I suspect it would
> considerably increase planning time, though maybe it also presents an
> opportunity for some interesting approaches to adaptive query execution.


What's the point, in the context of this example?

The sort-unique still has to be performed even if you didn't have data
in one side, since the other could still have duplicates.


-- 
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance



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

* Re: Adaptive query execution
  2014-05-13 20:08 Adaptive query execution Tim Kane <tim.kane@gmail.com>
  2014-05-13 20:13 ` Re: Adaptive query execution Claudio Freire <klaussfreire@gmail.com>
@ 2014-05-13 20:33   ` Tim Kane <tim.kane@gmail.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Tim Kane @ 2014-05-13 20:33 UTC (permalink / raw)
  To: Claudio Freire <klaussfreire@gmail.com>; +Cc: pgsql-performance

> 
> 
> From:  Claudio Freire <klaussfreire@gmail.com>
>>  I thought I would see what happens when I do this:
>> 
>>    SELECT * FROM ONLY table_a UNION SELECT * FROM table_b;
>> 
>> 
>> 
> What's the point, in the context of this example?
> 
> The sort-unique still has to be performed even if you didn't have data
> in one side, since the other could still have duplicates.


Damn it. Okay, bad example. I should sleep.

A better example would be (from my other post just now -
http://www.postgresql.org/message-id/CF9838D8.7EF3D%tim.kane@gmail.com )
where an empty parent-table is append’ed into a result set involving one
(and only one) of its child relations.  Whereas a more optimum solution
would involve only the child relation without the need to append the empty
parent relation.

I’m sure there are other scenarios where adaptive query execution would be
of greater benefit.

Tim







> 

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


end of thread, other threads:[~2014-05-13 20:33 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2014-05-13 20:08 Adaptive query execution Tim Kane <tim.kane@gmail.com>
2014-05-13 20:13 ` Claudio Freire <klaussfreire@gmail.com>
2014-05-13 20:33   ` Tim Kane <tim.kane@gmail.com>

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