UNPKG

bc-code-intelligence-mcp

Version:

BC Code Intelligence MCP Server - Complete Specialist Bundle with AI-driven expert consultation, seamless handoffs, and context-preserving workflows

94 lines (70 loc) 4.35 kB
--- title: "DeleteAll Performance Tradeoff" domain: "dean-debug" difficulty: "intermediate" bc_versions: "14+" tags: ["deleteall", "performance", "optimization", "tradeoffs"] prerequisites: ["deleteall-method-usage", "performance-fundamentals"] samples: "samples/deleteall-performance.md" --- # DeleteAll Performance Tradeoff ## Overview DeleteAll presents a fundamental performance tradeoff in BC: business logic compliance versus execution speed. While DeleteAll ensures complete business rule enforcement through OnDelete trigger execution, this comprehensive approach comes with significant performance implications. **Core Tradeoff**: Business logic completeness versus execution performance - DeleteAll prioritizes data integrity over speed. **Performance Reality**: DeleteAll operations typically perform 10-100x slower than direct SQL deletions due to individual record processing and trigger execution overhead. ## Strategic Framework ### Performance Cost Analysis **Execution Overhead Sources**: - Individual record processing rather than set-based operations - OnDelete trigger execution for every deleted record - Related table operations multiplying database interactions - Validation logic execution adding computational overhead - Transaction management extending operation duration ### Business Value Assessment **Data Integrity Benefits**: - Complete business rule enforcement during deletion operations - Proper audit trail and logging maintenance - Cascade delete operations preserving referential integrity - Custom validation logic execution ensuring data consistency - Related table synchronization maintaining system coherence ## Performance Impact Prediction ### Record Volume Sensitivity - Small datasets (< 1000 records): Performance impact typically acceptable - Medium datasets (1000-10000 records): Noticeable but manageable impact - Large datasets (> 10000 records): Significant performance degradation likely - Very large datasets (> 100000 records): Potentially prohibitive execution times ### Trigger Complexity Multiplier - Simple OnDelete triggers: Minimal additional overhead per record - Moderate trigger logic: 2-5x performance impact multiplication - Complex trigger operations: 10-50x performance impact multiplication - External system integration: Unpredictable and potentially severe impact ## Decision Guidelines ### When to Use DeleteAll - Business logic enforcement is critical for data integrity - Audit trail and logging must be maintained - Cascade delete operations are required - Related table synchronization is necessary - Custom validation logic must execute during deletion ### When to Consider Alternatives - Simple cleanup operations without business logic requirements - System maintenance operations where speed is critical - Temporary data removal with minimal related table impact - Bulk operations on isolated tables without complex relationships ## Best Practices ### Performance-Conscious Implementation - Limit DeleteAll operations to appropriate dataset sizes based on system capacity - Schedule large DeleteAll operations during low-usage periods - Implement batch processing for large datasets requiring business logic enforcement - Monitor system performance during deletion operations ### Decision Making Framework - Identify specific business logic requirements for deletion operations - Evaluate data integrity criticality versus performance needs - Assess related table impact and cascade operation requirements - Determine acceptable performance thresholds for user experience ## Anti-Patterns ### Performance Expectations Mismatch **Incorrect Assumption**: Expecting DeleteAll to perform comparably to direct SQL operations. DeleteAll prioritizes business logic compliance over speed, and trigger execution overhead is inherent. ### Inappropriate Usage Scenarios **Wrong Application**: Using DeleteAll for simple cleanup operations without business logic needs. Reserve DeleteAll for scenarios where business logic enforcement justifies performance cost. ### Scale Misunderstanding **Problematic Planning**: Underestimating performance impact at scale. Test DeleteAll performance with realistic production data volumes and complexity before implementation.