Description
Currently, we cache the AST of the query only and repeat the same calculations for each incoming query. They are generally very quick, but unnecessary - if the AST is the same, so will be the intermediate objects we construct to parse it.
We should cache most of these and apply only the last parameter sharding step on the cached intermediaries. This will reduce the number of memory allocations and will give us a few nanoseconds of latency back.
Examples
|
pub fn parse(stmt: &SelectStmt) -> Result<Self, Error> { |
|
let where_clause = WhereClause::new(table.map(|t| t.name), &stmt.where_clause); |
Description
Currently, we cache the AST of the query only and repeat the same calculations for each incoming query. They are generally very quick, but unnecessary - if the AST is the same, so will be the intermediate objects we construct to parse it.
We should cache most of these and apply only the last parameter sharding step on the cached intermediaries. This will reduce the number of memory allocations and will give us a few nanoseconds of latency back.
Examples
pgdog/pgdog/src/frontend/router/parser/aggregate.rs
Line 42 in a5dc504
pgdog/pgdog/src/frontend/router/parser/query/delete.rs
Line 9 in a5dc504