Fork me on GitHub
#honeysql
<
2022-03-27
>
orestis04:03:02

@dharrigan two things on your approach: 1. I've found that window functions (over) performed much worse than doing a completely separate query for the count. Not sure if something changed since I last tried. 2. I would construct the full select statically and then remove fields not present in the request. Much safer!

orestis04:03:31

Re: 2, I'm working on some code to do it. Can't promise it works on every kind of query but we've covered the common use case of renamed columns. Quite easy to do.

dharrigan06:03:29

Thanks! 🙂 Useful to know! 🙂

orestis07:03:22

The Postgres planner seemingly does a good job in ignoring unused stuff so even if your query uses joins etc, if you don't select something from joined tables they will be ignored.