Comments (4)
For uses of withPgClient that do not do mutations, am I right in understanding that by setting hasSideEffects = false
you can avoid the n+1 problem?
This is also hinted at here #2045
I wonder if there's value in adding a withReadOnlyPgClient
via a read only connection string that doesn't have side effects set to true. Or even just an example in the docs of how to wrap it with a call that sets hasSideEffects = false
and calls SET SESSION CHARACTERISTICS AS TRANSACTION READ ONLY
from crystal.
No, that is not correct. We added a warning right at the top of the docs page saying it doesn’t use batching:
https://grafast.org/grafast/step-library/dataplan-pg/withPgClient
Definitely worth looking out for these kinds of warnings. Might make sense for us to put “unbatched” in the name, perhaps.
We should maybe create a withBatchedPgClient
that works more like loadOne
/loadMany
; but really people should be using resources/codecs for this so that inlining can happen (in both directions), and that needs a bit of work to make it more ergonomic for common use cases.
from crystal.
would result in N+1 problem if applied to a non-root type
Is this true for any usage of withPgClient
for non root types?
Even if the withPgClient
step depends on no prior steps (passes null
as the second param)?
from crystal.
withPgClient
will run the callback the number of times that matches the batch size (N
) of the layer that it runs in (you can see the layer (or "bucket") it runs in by looking at the plan diagram). If you can trace from the root bucket to the bucket it's in without going through a listItem
or stream
bucket then the batch size is 1, so it will run once. If it's inside or descends from a listItem
bucket then it may run an arbitrary number of times, depending on the size of data you're handling.
Depending on null
as the second param does not guarantee that it will run only once, since that may happen in a situation where it cannot be "hoisted" (e.g. in a subprocedure or after a side effect or something). But in most cases, if you pass null
then it will indeed only call the callback once.
from crystal.
Related Issues (20)
- Current enum value isn't present on GraphQLEnumType_values_value scope HOT 2
- Planned module: @dataplan/graphql HOT 4
- Significant memory spike in plugin with each() HOT 3
- Grafast: garbage collection
- Grafast: hoisting of subroutines
- Exported PgCodec loses polymorphic information HOT 3
- PostGraphile docs: ambiguous example in makeExtendSchemaPlugin docs
- Document grafserv/envelop integration and how to add validation rules
- Graphile Export: detect hasOwn keys set on functions that aren't exportable
- Connection string with localhost don't work in library mode HOT 6
- "Gather" plugin example: treating unique indexes similarly to unique constraints HOT 1
- Document the new "early exit" and "global dependencies" features
- Epic: removing $step.eval()
- Masked errors when output to console should include path, etc.
- `makeWrapPlansAfterArgumentsHaveBeenAppliedPlugin` - solve confusion
- PostGraphileRelayPreset bug: mutation with "null" foreign key value does not work (returns null) HOT 1
- How does Postgraphile integrate with Apache AGE? HOT 1
- Polymorphism - union containing members of an interface plus another; how to plan?
- Create tests for middleware system (grafast, grafserv)
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 crystal.