Skip to content
David Buchmann edited this page Dec 9, 2019 · 6 revisions

Avoid having more than 10'000 direct children of one parent

As per http://wiki.apache.org/jackrabbit/Performance this can lead to performance problems.

Avoid the first PROPFIND on each session

Jackalope does a PROPFIND everytime you start a new Session. This first PROPFIND only checks if the repository exists. Nice for debugging and developing, waste of time in production.

As the JCR specs expect an exception on $repository->login() if the repository/workspace doesn't exist, we can't just remove it. But we made it optional. Do this

$parameters['jackalope.check_login_on_server'] = false;
... your other parameters
$repository = \Jackalope\RepositoryFactoryJackrabbit::getRepository($parameters);

and that PROPFIND goes away. If the workspace/repository doesn't exist or jackrabbit is down, you will get an exception when you first try to actually access it.

Use getRows if you search for something

Better do

$query = "SELECT foo, bar FROM [nt:unstructured]  WHERE some condition ORDER BY SCORE() DESC";
$q = $qm->createQuery($query, \PHPCR\Query\QueryInterface::JCR_SQL2);
$q->setLimit(10);
$qr = $q->execute();
foreach ($qr->getRows() as $n) {
    $foo =$n->getValue("foo");
}

than

$query = "SELECT * FROM [nt:unstructured]  WHERE some condition ORDER BY SCORE() DESC";
$q = $qm->createQuery($query, \PHPCR\Query\QueryInterface::JCR_SQL2);
$q->setLimit(10);
$qr = $q->execute();
foreach ($qr->getNodes() as $n) {
    $foo = $n->getAttribute("foo")->getValue();
}   

The second one has to do an additional HTTP Call to the jackrabbit server, while the first one gets everything in one call. This of course only works, if you know which columns you need

Large binaries handling

By default Jackalope enables a stream wrapper for all binaries. As a result binary data is lazy loaded. If you always need to read the binary data you can disable this

$parameters['jackalope.disable_stream_wrapper'] = false;
... your other parameters
$repository = \Jackalope\RepositoryFactoryJackrabbit::getRepository($parameters);