Too many same-level JCR entries

In JCR (Java Content Repository) and the Jackrabbit implementation of JCR, there’s no hard limit on the number of items that can exist at one level. However, the performance of the repository may degrade as the number of child items at a particular level increases.

The optimal number of child nodes per level depends on many factors, including the specific use case and the performance characteristics of the underlying storage system.

In general, for smooth performance, it’s recommended to limit the number of child nodes to a few hundred or less at each level.

Click to see a Groovy script to split flat structures into folders
folderSize = 100
workspace = "tours"
nodeType = "mgnl:content"
rootPath = "/magnolia-travels/"
query = "select * from [" + nodeType + "] WHERE ISDESCENDANTNODE('" + rootPath + "')"
session = MgnlContext.getJCRSession(workspace);
manager = session.getWorkspace().getQueryManager();
nodes = manager.createQuery(query, "JCR-SQL2").execute().nodes;
folderName = 0
nodesInFolder = 0
while (nodes.hasNext()) {
    folderPath = rootPath + folderName
    NodeUtil.createPath(session.rootNode, folderPath, "mgnl:folder");
    node = nodes.next()
    newPath = rootPath + folderName + "/" + node.name;
    if (node.path != newPath) { //repeatable script
        session.move(node.path, newPath);
    }
    if (nodesInFolder++ > folderSize) {
        nodesInFolder = 0
        folderName++
    }
}
session.save()
  • You can still retrieve the tree structure as a list through, for example, search templating functions.

  • Using a balanced tree structure, you can mitigate performance issues when publishing hundreds of items at once. See the itemsPerRequest property of the publish command.

Feedback

DX Core

×

Location

This widget lets you know where you are on the docs site.

You are currently perusing through the DX Core docs.

Main doc sections

DX Core Headless PaaS Legacy Cloud Incubator modules