我刚开始用Doctrine和Jackalope DBAL实现学习PHPCR。
使用Symfony 2调试工具栏我可以看到,对于简单表单并使用父属性选择,它需要15次查询(为了便于阅读而添加...
):
[2014-08-24 15:55:48] doctrine.DEBUG: SELECT ... FROM phpcr_workspaces ...
[2014-08-24 15:55:48] doctrine.DEBUG: SELECT ... FROM phpcr_namespaces
[2014-08-24 15:55:48] doctrine.DEBUG: SELECT ... FROM phpcr_type_nodes
[2014-08-24 15:55:48] doctrine.DEBUG: SELECT ... FROM phpcr_type_props ...
[2014-08-24 15:55:48] doctrine.DEBUG: SELECT ... FROM phpcr_type_childs ...
[2014-08-24 15:55:48] doctrine.DEBUG: SELECT ... FROM phpcr_type_nodes ...
[2014-08-24 15:55:48] doctrine.DEBUG: SELECT ... FROM phpcr_type_props ...
[2014-08-24 15:55:48] doctrine.DEBUG: SELECT ... FROM phpcr_type_childs ...
[2014-08-24 15:55:48] doctrine.DEBUG: SELECT ... FROM phpcr_nodes ...
[2014-08-24 15:55:48] doctrine.DEBUG: SELECT ... FROM phpcr_nodes ...
[2014-08-24 15:55:48] doctrine.DEBUG: SELECT ... FROM phpcr_nodes ...
[2014-08-24 15:55:48] doctrine.DEBUG: SELECT ... FROM phpcr_nodes ...
[2014-08-24 15:55:48] doctrine.DEBUG: SELECT ... FROM phpcr_nodes ...
[2014-08-24 15:55:48] doctrine.DEBUG: SELECT ... FROM phpcr_nodes ...
[2014-08-24 15:55:48] doctrine.DEBUG: SELECT ... FROM phpcr_nodes ...
我只有三个节点:
/
/root
/root/child
我添加了一个简单的表单(如here所述)来创建新文档并设置其父文件:
$form = $this->createFormBuilder($doc = new Document(), ['required' => false])
->add('name', 'text')
->add('title', 'text')
->add('parent', 'phpcr_document', [
'property' => 'id',
'class' => 'Acme\DemoBundle\Document\Document',
'multiple' => false,
])
->add('content', 'textarea')
->add('submit', 'submit')
->getForm()
->handleRequest($request);
if ($form->isValid()) {
// ...
}
return [('form' => $form->createView()];
如何降低查询次数?
答案 0 :(得分:0)
这里有几点需要考虑:
话虽如此,我们确实期望Jackalope Doctrine DBAL在性能方面仍有改进空间,但到目前为止,我们主要关注的是增加新功能。但是例如cmf.symfony.com在没有任何反向代理的SQLite上运行,但使用Jackalope Doctrine DBAL支持的元数据和节点缓存,并提供了相当可接受的性能。