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 subquery transformation for SIZE() select clauses #67

Closed
Mobe91 opened this issue Sep 1, 2014 · 2 comments
Closed

Optimize subquery transformation for SIZE() select clauses #67

Mobe91 opened this issue Sep 1, 2014 · 2 comments

Comments

@Mobe91
Copy link
Contributor

Mobe91 commented Sep 1, 2014

We could use the inverse mapping for creating the COUNT() subqueries. This way we could save a join.

@Mobe91 Mobe91 added this to the 1.1.0 milestone Sep 1, 2014
@beikov beikov changed the title Optimized subquery transformation for SIZE() select clauses Optimize subquery transformation for SIZE() select clauses Mar 12, 2015
@beikov beikov modified the milestones: 1.2.0, 1.1.0 Jan 23, 2016
@beikov
Copy link
Member

beikov commented Feb 9, 2016

I would like to recap what the intention of this issue was since it's very old now.

Right now, we transform SIZE functions into subqueries that do COUNT. When having

SELECT SIZE(a.collection) FROM A a

it get's transformed to

SELECT (SELECT COUNT(y) FROM A x LEFT JOIN x.collection y WHERE x.id = a.id) FROM A a

although it could be transformed into

SELECT (SELECT COUNT(y) FROM B y WHERE y.a.id = a.id) FROM A a

if we know the inverse relation.

According to the JPQL BNF we could also transform it into the following equivalent query

SELECT (SELECT COUNT(y) FROM a.collection y) FROM A a

which would be even easier.

@beikov
Copy link
Member

beikov commented Sep 30, 2016

Fixed

@beikov beikov closed this as completed Sep 30, 2016
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

2 participants