Fork me on GitHub

@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!


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.


Thanks! 🙂 Useful to know! 🙂


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.