Replies: 1 comment
-
|
From my experience on big data sets max and min are slower than sub select limit 1 with order. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently, latestOfMany/oldestOfMany use MAX/MIN to get the latest/oldest record of a relation:
If the "id" column is of UUID type, this fails in PostgreSQL because it doesn't support MAX/MIN on UUID columns and this is already stated in the Laravel docs.
When rewriting the latest/oldest sub-query to a SELECT with ORDER BY and LIMIT, latestOfMany/oldestOfMany could be supported easily when the sub-query looks like:
This query is also easier to optimize compared to the MAX/MIN and GROUP BY query.
Beta Was this translation helpful? Give feedback.
All reactions