Open aryascripts opened 2 weeks ago
I cannot reproduce the issue you describe (I have not broken out the profiling tools to check that way, just added logs)
Specifically here's my schema:
create table users (id serial primary key, username text not null unique);
insert into users (username) values ('Benjie'), ('Jem');
And my query:
query User($id:ID!) {
user(id:$id) {
id
username
}
}
And I run it with the variables:
{ "id": "WyJ1c2VycyIsMV0=" }
{ "id": "WyJ1c2VycyIsMl0=" }
I've added log messages around this section of establishOperationPlan:
like so:
and the output I get for running one id after the other is exactly what I'd expect (I've added extra newlines to make it easier to parse):
Server listening on port 5678 at http://[::]:5678/graphql
NO CACHE! IntrospectionQuery
NEW PLAN! IntrospectionQuery
REUSING OPERATION PLAN IntrospectionQuery
NO CACHE! User
NEW PLAN! User
REUSING OPERATION PLAN User
The first User
request had no cache, so required a new plan. The second User
request used the other value for id
, but was happy reusing the plan.
Please create a minimal reproduction on https://github.com/benjie/ouch-my-finger/
Summary
This is a question we have about the expectations of grafast and optimizations during operation plan creation.
We noticed that most of the time (close to 50%) in our node server was spent in these two functions/files in grafast:
prepare.js
)When reading the documentation for grafast, under "Getting the operation plan", it seems like operation plans should be saved for future use and optimizations.
However, after profiling what the cpu does for each request, it seems like the operation plans are only reuse when the operation body AND variables are exactly the same. Is this expected?
Additional context
How to replicate:
{ "id": 1 }
prepare.js
) are performed, all over againIf in step 3, we send
{ "id": 1 }
again as variables, then theprepare.js
is skipped, and it jumps toexecute.js
directly.I'm happy to provide even more additional context if necessary, but this is easy to replicate with any small server that can run postgraphile with PG.
Versions used
Screenshots of profiling
Request 1
Request 2
Command used: