MCPcopy Create free account
hub / github.com/erans/pgsqlite / should_use_statement_cache

Method should_use_statement_cache

src/optimization/statement_cache_optimizer.rs:204–235  ·  view source on GitHub ↗

Determine if a query should use statement caching based on pattern and hints

(&self, pattern: &QueryPattern, hints: &OptimizationHints)

Source from the content-addressed store, hash-verified

202
203 /// Determine if a query should use statement caching based on pattern and hints
204 fn should_use_statement_cache(&self, pattern: &QueryPattern, hints: &OptimizationHints) -> bool {
205 use crate::query::{QueryPattern, QueryComplexity};
206
207 match pattern {
208 // Always cache these high-value patterns
209 QueryPattern::SimpleSelect |
210 QueryPattern::SimpleInsert |
211 QueryPattern::SimpleUpdate |
212 QueryPattern::SimpleDelete |
213 QueryPattern::BatchInsert |
214 QueryPattern::CountQuery |
215 QueryPattern::MaxMinQuery => true,
216
217 // Cache if optimization hints suggest it's beneficial
218 QueryPattern::GroupByAggregation |
219 QueryPattern::OrderByLimit |
220 QueryPattern::JoinWithWhere |
221 QueryPattern::ExistsQuery |
222 QueryPattern::SubqueryExists => {
223 hints.use_prepared_statement && hints.complexity != QueryComplexity::Complex
224 },
225
226 // Only cache complex queries if explicitly recommended
227 QueryPattern::NestedSubquery |
228 QueryPattern::UnionQuery |
229 QueryPattern::ComplexQuery => {
230 hints.cache_result &&
231 hints.use_prepared_statement &&
232 hints.complexity == QueryComplexity::Medium
233 },
234 }
235 }
236
237 /// Check if query might need binary protocol support (return false to use fallback)
238 fn supports_binary_protocol(&self, query: &str) -> bool {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected