-
Notifications
You must be signed in to change notification settings - Fork 60
Performance Tips
As per http://wiki.apache.org/jackrabbit/Performance this can lead to performance problems.
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.
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
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);