Replies: 1 comment 2 replies
-
Let me try to summarize what you are asking:
For redusing There is already some conditional code for nested connection fields so that we don't do counts there if not necessary (those are much more expensive since they need to run subqueries), although this results in some of the worst code in the entire library. Modifying this to work with the above logic sounds awful, but I guess users would expect it to work similarly if top-level connections. As for allowing customization, I think it would be a quite difficult given that pagination is split in two places ( |
Beta Was this translation helpful? Give feedback.
-
As mentioned elsewhere, a project I'm working on is very happily using this project and GDX. 😁
We are encountering an "issue" which is arguably tangential to what this project purports to do (optimized queryset construction and avoidance of N+1s) but does share overlapping concerns and is probably very attractive to its users.
The issue is the
SELECT COUNT(*)
which is automatically generated in different places by Graphene and (I believe) by this library. This query is potentially problematic because 1) its output may not be used and 2) it can be very costly on Postgres (~400ms in some of real-world scenarios).This has been discussed at some length in the graphene-django issue tracker and there is a community/conventional "solution".
Unfortunately, I'm fairly certain the linked solution can't be used as a drop-in replacement in conjunction with this library. That solution may also break fundamental underpinnings of this library, like pagination. So, before I go down the path of dubious class extensions or forks of this project, I wanted to see if the maintainers or GDQO community had any thoughts about holistic approaches to this problem. Also, whether or not a PR would be considered.
Our use case is also slightly divergent from the linked one because, for performance reasons, we are also wanting to write custom SQL (which makes use of PG indexes) in the scenario where this query is required. So, I think an ideal solution would be some combination of the two (avoidance or optional customization).
As mentioned above, presumably this is a feature which others would find useful and it'd be great to have both that and my underlying assumption about whether this is even feasible in conjunction with this library validated.
Either way, I'll share what we learn here as we continue researching options.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions