prax_query/mem_optimize/mod.rs
1//! Advanced memory optimizations for prax-query.
2//!
3//! This module provides high-performance memory management utilities:
4//!
5//! - **Enhanced string interning**: Global and scoped interning with auto-intern for identifiers
6//! - **Typed arena allocators**: Efficient arena allocation for query builder chains
7//! - **Lazy schema parsing**: On-demand parsing of introspection results
8//!
9//! # Performance Gains
10//!
11//! | Optimization | Feature | Memory Reduction |
12//! |--------------|---------|------------------|
13//! | String interning | All query builders | 20-30% |
14//! | Arena allocation | High-throughput queries | 15-25% |
15//! | Lazy parsing | Introspection | 40-50% |
16//!
17//! # Example
18//!
19//! ```rust,ignore
20//! use prax_query::mem_optimize::{
21//! interning::{GlobalInterner, ScopedInterner},
22//! arena::{QueryArena, ArenaAllocated},
23//! lazy::{LazySchema, LazyColumn},
24//! };
25//!
26//! // Global string interning for identifiers
27//! let field = GlobalInterner::get().intern("user_id");
28//!
29//! // Scoped arena for query building
30//! let arena = QueryArena::new();
31//! arena.scope(|scope| {
32//! let filter = scope.alloc_filter(/* ... */);
33//! let query = scope.build_query(filter);
34//! query.to_sql() // Returns owned SQL, arena freed on scope exit
35//! });
36//!
37//! // Lazy schema parsing
38//! let schema = LazySchema::from_raw(raw_data);
39//! // Columns only parsed when accessed
40//! let name = schema.get_table("users")?.get_column("name")?.db_type();
41//! ```
42
43pub mod arena;
44pub mod interning;
45pub mod lazy;
46
47pub use arena::{ArenaScope, QueryArena, ScopedFilter, ScopedQuery, ScopedValue};
48pub use interning::{GlobalInterner, InternedStr, ScopedInterner, IdentifierCache};
49pub use lazy::{
50 LazyColumn, LazyForeignKey, LazyIndex, LazySchema, LazyTable, ParseOnDemand,
51};
52