3 ms·
SQL isn't composable. It would be great if it was, but it isn't. So we can use query builders or write our own, but we're going to have to compose queries at so
by from-nibly 2y ago
SQL isn't composable. It would be great if it was, but it isn't. So we can use query builders or write our own, but we're going to have to compose queries at some point.
- rented_mule 2y agoCommon Table Expressions enable a lot of composability. Using them can look like you're asking the DB to repeat a lot of work, but decent query optimizers eliminate much of that. https://www.craigkerstiens.com/2013/11/18/best-postgres-feature-youre-not-using/ https://www.craigkerstiens.com/2013/11/18/best-postgres-feat...
- danielheath 2y agoCommon table expressions do exist, and they compose ~alright (with the caveats that you're limited to unique names and they're kinda clunky and most ORMs don't play nice with them).
- somat 2y agoHow composable do you want it? When I want to make a complicated intermediate query that other queries can reference I create it as a view. I will admit that future me hates this sometimes when I need to dismantle several layers of views to change something. And some people hate to have logic in the database, Personaly I tolerate a little logic, but understand them who don't like it. any way, common table expressions (with subquery as ()...) are almost as composable as views. and have the benefit of being self contained in a single query.
- liontwist 2y agoviews are query composition