Thanks, but is it inefficient to query
Thanks, but is it inefficient to query for everything inside the convex function, map over the result, and return the result of the map? I understand it runs inside the db but it’s still inefficient doing that?
11 Replies
Nope, not any more inefficient than sql selecting fields, same basic operation
sorry moving into a thread here so we don't throw off the main chat
What you're speaking to is more the value prop of a columnnar database
No worries. I’m a bit confused though. If you run a query to get all users, it means you scan over the users table once. Then after you have users, you run a Typescript map to get the fields you want. That’s effectively two times running over the entire users table?
If I run sql and select fields, I just scan the table once, look up the fields in each row as I run.
To my knowledge, under the hood, your sql select statement is still getting entire rows, selecting fields, and then returning those in the result
So my point is that you're just manually doing what a sql statement will do
Uhm let me check. But I seriously think convex query should be extended to return selected fields.
Having to run map explicitly and stuff is a bit weird
Only if you're used to sql. But yeah, I do understand the perspective.
You can write a
select()
helper really quickly to give you the ergonomics you want.
But it isn't less efficient than sql selectThanks, I’ll keep this in mind. Again having something like
select()
like you just said built in would be so nice!At some point there will be one or more really great orm libs for Convex, Ents was an early attempt that kinda showed what's possible.
No one is working on anything I'm aware of lol, I just know it's going to happen at some point, even it comes from the community
To be honest I think using pure convex query right now is fine lol, just a few more convenient methods
yeah you get used to it
but I definitely understand for folks who are used to sql or full fledged orm's, Convex queries are very low level (they even say as much in the Zen of Convex doc)
What I appreciate about their approach is they've chosen not to make decisions rather than risk making the wrong ones and boxing everyone in.
I understand. I’ll check out the docs btw. Thanks again!