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()
|
See also Q. I have too many child nodes and performance goes down (Apache Jackrabbit Wiki). |