Article DetailsDetailsHelp DetailsProblem The DETACH DELETE Cypher operation performs with varying execution times when run against different environments, such as test and production. Cause Several environmental and operational factors can lead to performance differences: Data Volume DifferencesEven when using the same label, the number of nodes and relationships may differ significantly between environments. A higher number of relationships in production increases the cost of DETACH DELETE, as Neo4j must remove all connected relationships before deleting each node. Memory and Resource AvailabilityA test environment may have more available memory or fewer concurrent workloads, allowing the operation to complete faster. Production environments often operate under higher load or with tighter memory constraints, affecting query performance. Page Cache and Disk I/OLarger datasets in production may exceed the configured page cache size, resulting in more frequent disk reads. Disk I/O latency becomes a factor when data cannot be served from memory. Concurrent WorkloadsProduction systems usually support multiple users and background processes simultaneously. These concurrent workloads can lead to resource contention, impacting the speed of long-running operations like DETACH DELETE. Lock Contention on Nodes and RelationshipsNeo4j requires locks on relationships and nodes during deletion. If other processes are accessing or modifying the same elements, DETACH DELETE must wait for those locks to be released, potentially resulting in delays or transaction timeouts. Resolution To mitigate performance issues when deleting large volumes of data: Use batching techniques with apoc.periodic.iterate or CALL { ... } IN TRANSACTIONS to avoid long-running transactions. Large Delete Transaction Best Practices in Neo4j Ensure adequate page cache is configured relative to the dataset size. Use SHOW TRANSACTIONS to identify lock contention during query execution. SHOW TRANSACTIONS InformationTitleWhy DETACH DELETE May Perform Differently Between EnvironmentsArticle Created Date6/4/2025, 1:47 PMURL NameWhy-DETACH-DELETE-May-Perform-Differently-Between-EnvironmentsLast Modified Date6/4/2025, 2:31 PM