Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize non-ALL versions of set operations in Postgres serializer #66

Open
lordpretzel opened this issue Nov 15, 2020 · 0 comments
Open

Comments

@lordpretzel
Copy link
Collaborator

GProm's algebra uses bag versions of set operations. An input set version, is translated into the bag version plus duplicate elimination. When translating back in the serializer we just use the bag version. We should whether a set operation is used in conjunction with duplicate elimination and if that is the case use the set version instead.

SELECT * FROM r UNION SELECT * FROM s;

is translated into

DuplicateRemoval
  Union
    Projection [a b ]
      TableAccess [r]
    Projection [c d ]
      TableAccess [s]

and then serialized into

SELECT  DISTINCT F0."a" AS "a", F0."b" AS "b"
FROM ((
SELECT F0."a" AS "a", F0."b" AS "b"
FROM "r" AS F0 UNION ALL
SELECT F0."c" AS "c", F0."d" AS "d"
FROM "s" AS F0)) F0

when instead it would be better to generate

SELECT   F0."a" AS "a", F0."b" AS "b"
FROM ((
SELECT F0."a" AS "a", F0."b" AS "b"
FROM "r" AS F0 UNION
SELECT F0."c" AS "c", F0."d" AS "d"
FROM "s" AS F0)) F0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant