You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, there seems to be something wrong with the preparation of statement values. I'm experiencing weird unusual timings on example projects. Passing any values to ClientBase.query will cause very high timings, not doing so and just passing a statement has normal expected timings.
(async()=>{constclient=newClient({user: 'postgres',password: 'localserver',database: 'test2'})awaitclient.connect()constquery={name: 'test',text: 'SELECT * FROM post WHERE id = $1::integer',values: [1],}for(leti=0;i<10;i++){console.time(i.toString());constres=awaitclient.query(query)console.log(res.rows[0])console.timeEnd(i.toString());}awaitclient.end()})();
Please provide details about your environment (Node version, pg version, OS, are there containers/virtualization involved – e.g. Docker or WSL on either the Node or Postgres side). It’d be helpful to include the “just passing a statement” statement and timings for comparison, too, as well as timings using other client libraries.
And try SELECT $1 so it doesn’t depend on a schema or database contents.
This is most likely related to latency in your environment. Can you reproduce this entirely locally & demostrate the speed difference? 48 milliseconds for a single query is incredibly slow considering I get sub millisecond response times locally:
I'm running this code connecting on an m1 macbook pro to a local instance of postgres 14 (postgres.app for the win):
Hello, there seems to be something wrong with the preparation of statement values. I'm experiencing weird unusual timings on example projects. Passing any
values
toClientBase.query
will cause very high timings, not doing so and just passing a statement has normal expected timings.It seems to be caused by this code flow:
node-postgres/packages/pg/lib/query.js
Line 190 in 0096856
PoC
Result:
The text was updated successfully, but these errors were encountered: