drizzle-team / drizzle-orm

Headless TypeScript ORM with a head. Runs on Node, Bun and Deno. Lives on the Edge and yes, it's a JavaScript ORM too 😅
https://orm.drizzle.team
Apache License 2.0
24.61k stars 649 forks source link

[BUG]: db.query creates slow (?) queries in related queries #3581

Open gituser-rs opened 3 days ago

gituser-rs commented 3 days ago

Report hasn't been filed before.

What version of drizzle-orm are you using?

0.36.3

What version of drizzle-kit are you using?

0.28.1

Other packages

No response

Describe the Bug

I am new into SQL "Performance", but I guess SELECT * is not a good idea. I have checked for other reports, but found nothing related.

Here is the slice of query produced by drizzle:

 (SELECT json_array(`ads_user`.`support`) AS `data`
   FROM
     (SELECT * FROM `users` `ads_user` WHERE `ads_user`.`id` = `ads`.`userId` LIMIT 1) `ads_user`) `ads_user`

but SELECT ads_user.support works flawlessly

My relational query selects only support:

screenshot