Skip to content

Conversation

@grishinMV
Copy link

This PR optimizes DQL cache usage and prevents memory leaks in the NestedTreeRepository by replacing direct value interpolation with parameterized queries.

Performance Impact
This change prevents the creation of excessive DQL cache entries by ensuring that queries with different values use the same parameterized DQL structure.

Before changes (direct value interpolation):

php
// Each unique value combination created a new DQL string:
$dql1 = "SELECT node FROM Entity\Category WHERE node.lft <= 5 AND node.rgt >= 10"
$dql2 = "SELECT node FROM Entity\Category WHERE node.lft <= 15 AND node.rgt >= 20"
$dql3 = "SELECT node FROM Entity\Category WHERE node.lft <= 25 AND node.rgt >= 30"
// Result: 1000 different nodes → 1000 unique DQL strings in cache

After changes (parameterized queries):

php
// Single DQL string reused for all queries:
$dql = "SELECT node FROM Entity\Category WHERE node.lft <= :left AND node.rgt >= :right"

@phansys phansys added the Tree label Nov 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants