Comments (3)
Types are only fetched at first connect. Are you running on some edge host? You can disable with fetch_types: false
from postgres.
@porsager Hey, this is not running on an edge host. The problem is, disabling fetch_types throws some exceptions as it can't resolve a type from an array it seems. It seems to be re-fetching the types on each connection in the pool, so when I have a lot of transactions and it grabs different connections, it will indeed re-fetch the types.
When there are high amount of concurrent queries, postgres will open as many connections as needed up until max number of connections is reached. By default max is 10. This can be changed by setting max in the postgres() call. Example - postgres('connectionURL', { max: 20 }).
This means that we get a much simpler story for error handling and reconnections. Queries will be sent over the wire immediately on the next available connection in the pool. Connections are automatically taken out of the pool if you start a transaction using sql.begin(), and automatically returned to the pool once your transaction is done.
^ The README explains that behavior, except the part that it re-fetches all types. Is there any possible way to cache the types? We have a ton of concurrent queries as it's an gameserver, it not caching and re-fetching the types is quite time consuming as we have a big database. We noticed high delays on a big player count (stuff that requires knowing array types, as that plays a role) and when we had a lot of concurrent queries going on at startup which was eating some seconds of boot time.
from postgres.
https://github.com/porsager/postgres/blob/master/src/connection.js#L743
This seems to be it, as needsTypes
is scoped per connection and thus resulting in the re-fetch instead of re-using the already known types from a previous connection.
from postgres.
Related Issues (20)
- Unable to query structured data
- Interpolation example in docs flagged as error HOT 1
- Get the number of available connections
- exclude pg_stat_statements logging for a procedure call HOT 1
- Dot and Periods can't be used as values HOT 1
- Problem executing Common Table Expression (WITH query) HOT 3
- π Is it possible to provide more information in the error output? HOT 4
- Is there a plan to support JSON path query for JSON/JSONBοΌ
- No overload matches this call
- READABLE from COPY does not recieve close event
- Handy helper in node-postgres: allowExitOnIdle
- Get pending queries length
- Never-ending CONNECTION_CLOSED errors
- TypeError: Cannot read properties of undefined (reading 'replace') HOT 1
- TypeError: Cannot redefine property: query
- A reserved/released ReservedSql prevents the main Sql from ending
- Readme `debug: true` inconsistency HOT 1
- How to connect my db running on a private network? HOT 2
- UnhandledSchemeError: cloudflare when Using postgres with Cloudflare Workers and Next.js Edge Runtime HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from postgres.