presto icon indicating copy to clipboard operation
presto copied to clipboard

Optimize union over empty values node

Open rschlussel opened this issue 4 years ago • 3 comments

Sometimes we see a union of a table scan and an empty values node when one side of the union has a partition filter for a partition that does not exist. This can lead to an inefficient plan, as in some circumstances it can cause the whole union stage to be executed on a single node. The empty values node is not really needed, as it's not meaningful to union something to an empty values node (or anything where the number of rows is known to be 0)

  1. if it is a union with multiple nodes, and at least two aren't zero cardinality, then remove the zero cardinality children
  2. If it is a union with only one non-zero cardinality node, replace the union with the non-zero child
  3. If it is a union only of zero cardinality nodes, replace the union with an empty values node.

rschlussel avatar Oct 07 '20 15:10 rschlussel

I would like to work on this issue, can I give it a shot?

miguelknb avatar Nov 10 '20 16:11 miguelknb

Absolutely!

rschlussel avatar Nov 11 '20 15:11 rschlussel

Hello! I would like to take a shot at implementing this.

bearownage avatar Feb 23 '24 21:02 bearownage

Hi @bearownage. I believe this issue was actually fixed by https://github.com/prestodb/presto/pull/19465. I'll close the issue.

rschlussel avatar Mar 05 '24 14:03 rschlussel