whatisagi
whatisagi2w ago

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
erquhart
erquhart2w ago
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
Omar
Omar2w ago
What you're speaking to is more the value prop of a columnnar database
whatisagi
whatisagiOP2w ago
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.
erquhart
erquhart2w ago
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
whatisagi
whatisagiOP2w ago
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
erquhart
erquhart2w ago
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 select
whatisagi
whatisagiOP2w ago
Thanks, I’ll keep this in mind. Again having something like select() like you just said built in would be so nice!
erquhart
erquhart2w ago
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
whatisagi
whatisagiOP2w ago
To be honest I think using pure convex query right now is fine lol, just a few more convenient methods
erquhart
erquhart2w ago
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.
whatisagi
whatisagiOP2w ago
I understand. I’ll check out the docs btw. Thanks again!

Did you find this page helpful?