You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 13, 2020. It is now read-only.
Provide API to support Postgres query extension SELECT DISTINCT ON (..)
SELECT DISTINCTON (c.id)
c.id, e.dateFROM city c JOIN events e ONc.id=e.city_idWHEREc.idIN (....)
ORDER BYc.id, e.dateDESC
These type of queries run usually a lot faster than the common e.date = (SELECT max(e2.date) ...) subquery solution to find the latest event date per city.
Proposed API
Similar do setDistinct(boolean) Ebean could provide setDistinctOn(<column alias>...), e.g.
varcity = QCity.alias();
query.setDistinctOn(city.id) // varargs parameter to support more columns
I don't know if Ebean does query checking, but if it does, then it would be worth a warning if both conditions below are not true for such a query. Otherwise the query result will be unpredictable.
1. columns in DISTINCT ON should match left most columns in ORDER BY
2. number of columns in ORDER BY > number of columns in DISTINCT ON
The text was updated successfully, but these errors were encountered:
Provide API to support Postgres query extension
SELECT DISTINCT ON (..)
These type of queries run usually a lot faster than the common
e.date = (SELECT max(e2.date) ...)
subquery solution to find the latest event date per city.Proposed API
Similar do
setDistinct(boolean)
Ebean could providesetDistinctOn(<column alias>...)
, e.g.I don't know if Ebean does query checking, but if it does, then it would be worth a warning if both conditions below are not true for such a query. Otherwise the query result will be unpredictable.
The text was updated successfully, but these errors were encountered: