Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

[performance] pg-native first query is 10x/20x slower compared to pg (parallel requests) #92

Open
CristianPi opened this issue May 21, 2020 · 0 comments

Comments

@CristianPi
Copy link

Hi,

i'm making some parallel requests (local db), let's say 3/4 request to the same table, very basic query:

4x of select * from user where id = $1
running in parallel with Promise.all()

when i make the first 4 parallel requests i see a completion time of around 60ms.
calling again the code, it's much faster, ~5ms.
if i wait ~10 second, and call again the code is see again the 60ms delay,
like if the pg client needs to connect to the db, and after a shot timeout, it disconnects.

i'm using the library as it's the same as the pg javascript client (so i can switch to the native and back with easy).
no special settings, only the stuff for connecting to the database.

using the pg javascript library i only see a first delay of around ~9 - 11 ms.

if i use the pg-native client without running parallel request i don't see the huge delay of 60ms, just ~7ms.

it's probably connected somehow to pools and timeouts, any way to improve those first query?

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

No branches or pull requests

1 participant