The relatively new QuerySet.union operator has quite a few limitations:
[...] only LIMIT, OFFSET, COUNT(*), ORDER BY, and specifying columns (i.e.
> slicing, count(), order_by(), and values()/values_list()) are allowed on
> the resulting QuerySet. Further, databases place restrictions on what
> operations are allowed in the combined queries. For example, most databases
> don’t allow LIMIT or OFFSET in the combined queries.
>
I think most of these could be circumvented by having the combined queries
wrapped as subqueries, e.g.:
SELECT * FROM (
SELECT f1, f2 FROM t1 ORDER BY f2 OFFSET 10
)
UNION
SELECT * FROM (
SELECT f1, f2 FROM t2 ORDER BY f1 DESC LIMIT 3
)
As far as I know, all relevant databases support this workaround and there
isn't any performance penalty to it. Am I missing something?
— Thijs
--
You received this message because you are subscribed to the Google Groups
"Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-developers/1e029596-3fd7-4796-988a-5aa51c522269%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.