Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add postgres array constructor for subqueries #1291

Open
SimonSimCity opened this issue Dec 12, 2024 · 0 comments
Open

Add postgres array constructor for subqueries #1291

SimonSimCity opened this issue Dec 12, 2024 · 0 comments

Comments

@SimonSimCity
Copy link

SimonSimCity commented Dec 12, 2024

I was scowarding through tickets on this repo and found a lot of things related to arrays, but I'm particularly interested in writing a typed query for postgres, where I can use an array constructor for a sub-query:

select *, array(select row(comments.*) from comments where posts.id = comments.post_id) from posts

The last example on https://www.postgresql.org/docs/current/sql-expressions.html#SQL-SYNTAX-ARRAY-CONSTRUCTORS shows the SQL I want to write.

My goal is to conquer cartesian explosion and still keep writing just one query. As of now, I'm calling multiple queries (split-query approach).

Sidenote: #649 seems like a valid approach, but there you're still joining. I don't know what would be better performance wise. I found one mentioning performance testing and optimizing query plans (npgsql/efcore.pg#1691).. In fact, I'm quite new to this topic and want to write scalable code 😎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant