A SPARQL request that carries a # PRAGMA comment is still parsed more than once. Each layer that applies a pragma reads it from the text with fluree_db_sparql::request_pragmas, and that function runs a full parse. Requests without a pragma comment skip it, because request_pragmas returns early unless some # comment could be a directive.
#2002 removed the extra parse wherever the API already holds the AST: the view and dataset query paths now build their fuel and tracking trackers from ast.pragmas. These extra parses remain, per pragma-bearing request:
| Route |
Extra parses |
Where |
| Server query (any SPARQL route) |
1 |
FlureeHeaders::with_sparql_request_pragmas; the route then parses again for its dataset-warning headers |
FromQueryBuilder / GraphQueryBuilder with no caller policy |
+1 |
GovernanceOptions::from_sparql, before the view loads |
| Connection-scoped tracked query, no tracking override |
+1 |
the floor tracker in query/connection.rs |
| Multi-query SPARQL alias |
3 |
server min-t collection, server alias authorization (sparql_alias_pragma_opts), dispatcher (sparql_pragma_opts) |
| SPARQL UPDATE with no tracking headers |
2 |
server header merge, TransactCore::tracker |
The cost only matters for large request bodies (multi-MB VALUES payloads) that also carry a pragma.
Possible approach: parse once at the entry point and carry the result down.
- The server parses once per route and takes the pragmas from that
ParseOutput, merging them into the headers and reusing it for the warning headers.
- The API builders accept already-extracted
Pragmas (or the AST) so policy adoption and trackers don't re-read the text.
- The multi-query server pass hands the alias's pragmas to the dispatcher instead of the dispatcher re-reading them.
This touches signatures in about 15 places in the server and API, which is why #2002 left it out.
A SPARQL request that carries a
# PRAGMAcomment is still parsed more than once. Each layer that applies a pragma reads it from the text withfluree_db_sparql::request_pragmas, and that function runs a full parse. Requests without a pragma comment skip it, becauserequest_pragmasreturns early unless some#comment could be a directive.#2002 removed the extra parse wherever the API already holds the AST: the view and dataset query paths now build their fuel and tracking trackers from
ast.pragmas. These extra parses remain, per pragma-bearing request:FlureeHeaders::with_sparql_request_pragmas; the route then parses again for its dataset-warning headersFromQueryBuilder/GraphQueryBuilderwith no caller policyGovernanceOptions::from_sparql, before the view loadsquery/connection.rssparql_alias_pragma_opts), dispatcher (sparql_pragma_opts)TransactCore::trackerThe cost only matters for large request bodies (multi-MB
VALUESpayloads) that also carry a pragma.Possible approach: parse once at the entry point and carry the result down.
ParseOutput, merging them into the headers and reusing it for the warning headers.Pragmas(or the AST) so policy adoption and trackers don't re-read the text.This touches signatures in about 15 places in the server and API, which is why #2002 left it out.