Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

What other approaches to making SQL composable can we imagine? With functions it seems very simple to extract a WHERE clause into a predicate of some sort. I'm sure even if this exact syntax isn't preferable, being able to reuse join logic would be great.

That said, in the case of wanting to abstract out or reuse joins, just write a view, I guess. And I get a lot of mileage in Postgres from just writing functions to abstract out predicates, because it allows you to write things like `select * from order where order.is_complete` instead of `where is_complete(order)`



Forgive me for asking a simplistic question: What’s the advantage for you to write these as functions rather than, say, adding a new column in a view?

Would you use the same predicate on multiple tables? Is there a performance benefit?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: