9 種類のノード、9 種類の関係、および 50 のエントリ (ノードと関係) を持つデータベースがあります。新しいノードを保存しようとすると、ライブラリは関数で 140 のクエリを実行します。
私のPHPコード:
$iUser = new User();
$iUser->setEmail($mail);
$iUser->setName($name);
$this->getEntityManager()->persist($iUser); // <-- It's do 140 queries
$this->getEntityManager()->flush();
クラス定義
/** @OGM\Node(label="User") */
class User {
@OGM\GraphId()
private $id;
/** @OGM\Property(type="string") */
private $name;
/** @OGM\Property(type="string") */
private $mail;
// Set, genters, ...
}
ライブラリのバージョン:
graphaware/neo4j-bolt 1.10.0
graphaware/neo4j-common 3.5.0
graphaware/neo4j-php-client 4.8.1
graphaware/neo4j-php-ogm 1.0.0-RC5
クエリは、データベース内の関係およびその他の ID に対して常に繰り返されます。同じクエリで、名前の関係または ID が変更されます。クエリは次のとおりです。
クエリ
MATCH (n) WHERE id(n) = {id} RETURN size((n)<-[:`<name relation>`]-()) AS users
Parameter: array:1 [▼
"id" => 189
]
MATCH (n) WHERE id(n) = {id} MATCH (n)<-[vendor_neo4j_entity_roleentity_users:`HAVE_ROL_GLOBAL`]-(vendor_neo4j_entity_haverolglobalrelationship) RETURN {target: startNode(vendor_neo4j_entity_roleentity_users), re: vendor_neo4j_entity_roleentity_users} AS vendor_neo4j_entity_roleentity_users
Parameter: array:1 [▼
"id" => 189
]
コードの最初のクエリ トレース
0 => array:4 [▼
"file" => "C:\wamp64\www\vCheck\vendor\graphaware\neo4j-php-ogm\src\Persisters\BasicEntityPersister.php"
"line" => 131
"function" => "run"
"class" => "GraphAware\Neo4j\Client\Client"
]
1 => array:4 [▼
"file" => "C:\wamp64\www\vCheck\vendor\graphaware\neo4j-php-ogm\src\Proxy\RelationshipEntityCollectionInitializer.php"
"line" => 29
"function" => "getCountForRelationship"
"class" => "GraphAware\Neo4j\OGM\Persisters\BasicEntityPersister"
]
2 => array:4 [▼
"file" => "C:\wamp64\www\vCheck\vendor\graphaware\neo4j-php-ogm\src\Proxy\LazyCollection.php"
"line" => 87
"function" => "getCount"
"class" => "GraphAware\Neo4j\OGM\Proxy\RelationshipEntityCollectionInitializer"
]
3 => array:4 [▼
"file" => ""
"line" => 0
"function" => "count"
"class" => "GraphAware\Neo4j\OGM\Proxy\LazyCollection"
]
4 => array:4 [▼
"file" => "C:\wamp64\www\vCheck\vendor\graphaware\neo4j-php-ogm\src\UnitOfWork.php"
"line" => 493
"function" => "count"
"class" => ""
]
5 => array:4 [▼
"file" => "C:\wamp64\www\vCheck\vendor\graphaware\neo4j-php-ogm\src\UnitOfWork.php"
"line" => 150
"function" => "traverseRelationshipEntities"
"class" => "GraphAware\Neo4j\OGM\UnitOfWork"
]
6 => array:4 [▼
"file" => "C:\wamp64\www\vCheck\vendor\graphaware\neo4j-php-ogm\src\UnitOfWork.php"
"line" => 501
"function" => "doPersist"
"class" => "GraphAware\Neo4j\OGM\UnitOfWork"
]
7 => array:4 [▼
"file" => "C:\wamp64\www\vCheck\vendor\graphaware\neo4j-php-ogm\src\UnitOfWork.php"
"line" => 150
"function" => "traverseRelationshipEntities"
"class" => "GraphAware\Neo4j\OGM\UnitOfWork"
]
8 => array:4 [▼
"file" => "C:\wamp64\www\vCheck\vendor\graphaware\neo4j-php-ogm\src\UnitOfWork.php"
"line" => 123
"function" => "doPersist"
"class" => "GraphAware\Neo4j\OGM\UnitOfWork"
]
9 => array:4 [▼
"file" => "C:\wamp64\www\vCheck\vendor\graphaware\neo4j-php-ogm\src\EntityManager.php"
"line" => 223
"function" => "persist"
"class" => "GraphAware\Neo4j\OGM\UnitOfWork"
]
10 => array:4 [▼
"file" => "C:\wamp64\www\vCheck\src\vendor\Neo4j\Repository\UserRepository.php"
"line" => 184
"function" => "persist"
"class" => "GraphAware\Neo4j\OGM\EntityManager"
]
11 => array:4 [▼
"file" => "C:\wamp64\www\vCheck\src\vendor\CoreBundle\Controller\UsersController.php"
"line" => 214
"function" => "editUser"
"class" => "vendor\Neo4j\Repository\UserRepository"
]
12 => array:4 [▼
"file" => ""
"line" => 0
"function" => "saveUserAction"
"class" => "vendor\CoreBundle\Controller\UsersController"
]
13 => array:4 [▼
"file" => "C:\wamp64\www\vCheck\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\HttpKernel.php"
"line" => 153
"function" => "call_user_func_array"
"class" => ""
]
14 => array:4 [▼
"file" => "C:\wamp64\www\vCheck\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\HttpKernel.php"
"line" => 68
"function" => "handleRaw"
"class" => "Symfony\Component\HttpKernel\HttpKernel"
]
15 => array:4 [▼
"file" => "C:\wamp64\www\vCheck\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\Kernel.php"
"line" => 171
"function" => "handle"
"class" => "Symfony\Component\HttpKernel\HttpKernel"
]
16 => array:4 [▼
"file" => "C:\wamp64\www\vCheck\web\app.php"
"line" => 20
"function" => "handle"
"class" => "Symfony\Component\HttpKernel\Kernel"
2 番目のクエリ トレース
0 => array:4 [▼
"file" => "C:\wamp64\www\vCheck\vendor\graphaware\neo4j-php-ogm\src\Persisters\BasicEntityPersister.php"
"line" => 122
"function" => "run"
"class" => "GraphAware\Neo4j\Client\Client"
]
1 => array:4 [▼
"file" => "C:\wamp64\www\vCheck\vendor\graphaware\neo4j-php-ogm\src\Proxy\RelationshipEntityCollectionInitializer.php"
"line" => 22
"function" => "getRelationshipEntityCollection"
"class" => "GraphAware\Neo4j\OGM\Persisters\BasicEntityPersister"
]
2 => array:4 [▼
"file" => "C:\wamp64\www\vCheck\vendor\graphaware\neo4j-php-ogm\src\Proxy\LazyCollection.php"
"line" => 52
"function" => "initialize"
"class" => "GraphAware\Neo4j\OGM\Proxy\RelationshipEntityCollectionInitializer"
]
3 => array:4 [▼
"file" => "C:\wamp64\www\vCheck\vendor\doctrine\collections\lib\Doctrine\Common\Collections\AbstractLazyCollection.php"
"line" => 332
"function" => "doInitialize"
"class" => "GraphAware\Neo4j\OGM\Proxy\LazyCollection"
]
4 => array:4 [▼
"file" => "C:\wamp64\www\vCheck\vendor\doctrine\collections\lib\Doctrine\Common\Collections\AbstractLazyCollection.php"
"line" => 274
"function" => "initialize"
"class" => "Doctrine\Common\Collections\AbstractLazyCollection"
]
5 => array:4 [▼
"file" => "C:\wamp64\www\vCheck\vendor\graphaware\neo4j-php-ogm\src\UnitOfWork.php"
"line" => 497
"function" => "getIterator"
"class" => "Doctrine\Common\Collections\AbstractLazyCollection"
]
6 => array:4 [▼
"file" => "C:\wamp64\www\vCheck\vendor\graphaware\neo4j-php-ogm\src\UnitOfWork.php"
"line" => 150
"function" => "traverseRelationshipEntities"
"class" => "GraphAware\Neo4j\OGM\UnitOfWork"
]
7 => array:4 [▼
"file" => "C:\wamp64\www\vCheck\vendor\graphaware\neo4j-php-ogm\src\UnitOfWork.php"
"line" => 501
"function" => "doPersist"
"class" => "GraphAware\Neo4j\OGM\UnitOfWork"
]
8 => array:4 [▼
"file" => "C:\wamp64\www\vCheck\vendor\graphaware\neo4j-php-ogm\src\UnitOfWork.php"
"line" => 150
"function" => "traverseRelationshipEntities"
"class" => "GraphAware\Neo4j\OGM\UnitOfWork"
]
9 => array:4 [▼
"file" => "C:\wamp64\www\vCheck\vendor\graphaware\neo4j-php-ogm\src\UnitOfWork.php"
"line" => 123
"function" => "doPersist"
"class" => "GraphAware\Neo4j\OGM\UnitOfWork"
]
10 => array:4 [▼
"file" => "C:\wamp64\www\vCheck\vendor\graphaware\neo4j-php-ogm\src\EntityManager.php"
"line" => 223
"function" => "persist"
"class" => "GraphAware\Neo4j\OGM\UnitOfWork"
]
11 => array:4 [▼
"file" => "C:\wamp64\www\vCheck\src\vendor\Neo4j\Repository\UserRepository.php"
"line" => 184
"function" => "persist"
"class" => "GraphAware\Neo4j\OGM\EntityManager"
]
12 => array:4 [▼
"file" => "C:\wamp64\www\vCheck\src\vendor\CoreBundle\Controller\UsersController.php"
"line" => 214
"function" => "editUser"
"class" => "vendor\Neo4j\Repository\UserRepository"
]
13 => array:4 [▼
"file" => ""
"line" => 0
"function" => "saveUserAction"
"class" => "vendor\CoreBundle\Controller\UsersController"
]
14 => array:4 [▼
"file" => "C:\wamp64\www\vCheck\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\HttpKernel.php"
"line" => 153
"function" => "call_user_func_array"
"class" => ""
]
15 => array:4 [▼
"file" => "C:\wamp64\www\vCheck\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\HttpKernel.php"
"line" => 68
"function" => "handleRaw"
"class" => "Symfony\Component\HttpKernel\HttpKernel"
]
16 => array:4 [▼
"file" => "C:\wamp64\www\vCheck\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\Kernel.php"
"line" => 171
"function" => "handle"
"class" => "Symfony\Component\HttpKernel\HttpKernel"
]
17 => array:4 [▼
"file" => "C:\wamp64\www\vCheck\web\app.php"
"line" => 20
"function" => "handle"
"class" => "Symfony\Component\HttpKernel\Kernel"
]
誰かがこれを解決することを知っていますか?