unkey icon indicating copy to clipboard operation
unkey copied to clipboard

Figure out how to do parallel db queries correctly without Promise.all

Open chronark opened this issue 1 year ago • 10 comments

See https://github.com/mattrobenolt/ps-http-sim/issues/7

chronark avatar Dec 20 '23 15:12 chronark

maybe async.parallel may work without causing error?

ErrolFernandes avatar Dec 20 '23 19:12 ErrolFernandes

What's that? I've never heard of it before?

chronark avatar Dec 20 '23 20:12 chronark

Async is a utility library it has something called async.parallel More here: https://medium.com/@jomote/a-comprehensive-guide-to-using-async-parallel-in-node-js-df51b1bf81a4

ErrolFernandes avatar Dec 20 '23 20:12 ErrolFernandes

I don't think this solves the underlying issue and also will likely not run in workerd

chronark avatar Dec 21 '23 09:12 chronark

what is the underlying issue though?

ErrolFernandes avatar Dec 21 '23 10:12 ErrolFernandes

It's explained in the issue I linked above https://github.com/mattrobenolt/ps-http-sim/issues/7

chronark avatar Dec 21 '23 10:12 chronark

I'm not getting the deeper issue. I'm assuming this has to do with running concurrent queries. If so does the database has concurrent query limit and this is exceeding it?

ErrolFernandes avatar Dec 21 '23 10:12 ErrolFernandes

https://github.com/mattrobenolt/ps-http-sim/issues/7#issuecomment-1894607212

I didn't want to submit a PR since I have no way to test any of this or what unkey is, but:

https://github.com/unkeyed/unkey/blob/main/tools/bootstrap/main.ts#L32-L42

If you change this to use new Client(...) rather than connect(...) should work just fine.

You might have to do this to shut up the TypeScript type checker: https://github.com/drizzle-team/drizzle-orm/pull/1801#issuecomment-1894593875 until that PR is merged.

mattrobenolt avatar Jan 16 '24 22:01 mattrobenolt

Thanks @mattrobenolt, this is great, I'll check it out!

chronark avatar Jan 17 '24 09:01 chronark