0.7.5 - query routing bug fix & performance improvements
Release 0.7.5 - Query Routing & Performance Improvements
This release focuses on critical bug fixes for batch operations and significant performance optimisations.
Fixed
Query/Execute Routing for Batch Operations
- Implemented proper query() vs execute() routing in batch operations based on statement type
- execute_batch() now automatically detects SELECT and RETURNING clauses to use the correct LibSQL method
- execute_transactional_batch() applies the same intelligent routing logic for atomic operations
- execute_batch_native() and execute_transactional_batch_native() now properly route SQL batch execution
- Eliminates "Statement does not return data" errors for operations that should return rows
- All operations with RETURNING clauses now correctly use the query() method
Performance: Batch Operation Optimisations
- Eliminated per-statement argument clones in batch operations for better memory efficiency
- Changed batch_stmts.iter() to batch_stmts.into_iter() to consume vectors by value
- Removed unnecessary args.clone() calls in both transactional and non-transactional batches
- Reduces memory allocations during batch execution for improved throughput
Lock Coupling Reduction
- Dropped outer LibSQLConn mutex guard earlier in batch operations to reduce contention
- Extract inner Arc<Mutexlibsql::Connection> before entering async blocks
- Only hold inner connection lock during actual I/O operations
- Applied to all four batch operation variants:
- execute_batch()
- execute_transactional_batch()
- execute_batch_native()
- execute_transactional_batch_native()
- Reduces contention and deadlock surface area by following the established pattern from query_args()
Test Coverage & Documentation
- Enhanced should_use_query() test coverage for block comment handling
- Added explicit assertion documenting known limitation: RETURNING in block comments detected as false positive (safe behaviour)
- Documented CTE and EXPLAIN detection limitations with clear scope notes
- Added comprehensive future improvement recommendations with priority levels and implementation sketches
- Added performance budget notes for optimisation efforts
Impact
- Correctness: Batch operations with RETURNING clauses now work correctly
- Performance: Reduced memory allocations and lock contention in batch operations
- Reliability: Lower deadlock risk through improved lock coupling patterns
- Maintainability: Better test coverage and documentation for edge cases
Full Changelog: 0.7.0...0.7.5