dtsnx44260 2017-07-10 06:54
浏览 87

140函数中的查询仍然存在(适用于PHP的Neo4j graphaware OGM)

I have a database with 9 types of node, 9 types of relationship and 50 entries (nodes and relations), when I try to save a new node the library do 140 queries in function persist.

My PHP Code :

$iUser = new User();
$iUser->setEmail($mail);
$iUser->setName($name);
$this->getEntityManager()->persist($iUser); // <-- It's do 140 queries
$this->getEntityManager()->flush();

The class definition

/** @OGM\Node(label="User") */
class User {
    @OGM\GraphId()
    private $id;
    /** @OGM\Property(type="string") */
    private $name;
    /** @OGM\Property(type="string") */
    private $mail;

    // Set, genters, ...
}

Libraries version:

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

The queries repeat for relations and others IDs in database all time, is the same query change the name relation or ID, the queries are:

Queries

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
]

First query trace of code

0 => array:4 [▼
      "file" => "C:\wamp64\www\vCheck\vendor\graphaware
eo4j-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
eo4j-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
eo4j-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
eo4j-php-ogm\src\UnitOfWork.php"
      "line" => 493
      "function" => "count"
      "class" => ""
    ]
    5 => array:4 [▼
      "file" => "C:\wamp64\www\vCheck\vendor\graphaware
eo4j-php-ogm\src\UnitOfWork.php"
      "line" => 150
      "function" => "traverseRelationshipEntities"
      "class" => "GraphAware\Neo4j\OGM\UnitOfWork"
    ]
    6 => array:4 [▼
      "file" => "C:\wamp64\www\vCheck\vendor\graphaware
eo4j-php-ogm\src\UnitOfWork.php"
      "line" => 501
      "function" => "doPersist"
      "class" => "GraphAware\Neo4j\OGM\UnitOfWork"
    ]
    7 => array:4 [▼
      "file" => "C:\wamp64\www\vCheck\vendor\graphaware
eo4j-php-ogm\src\UnitOfWork.php"
      "line" => 150
      "function" => "traverseRelationshipEntities"
      "class" => "GraphAware\Neo4j\OGM\UnitOfWork"
    ]
    8 => array:4 [▼
      "file" => "C:\wamp64\www\vCheck\vendor\graphaware
eo4j-php-ogm\src\UnitOfWork.php"
      "line" => 123
      "function" => "doPersist"
      "class" => "GraphAware\Neo4j\OGM\UnitOfWork"
    ]
    9 => array:4 [▼
      "file" => "C:\wamp64\www\vCheck\vendor\graphaware
eo4j-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"

Second Query trace

0 => array:4 [▼
  "file" => "C:\wamp64\www\vCheck\vendor\graphaware
eo4j-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
eo4j-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
eo4j-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
eo4j-php-ogm\src\UnitOfWork.php"
  "line" => 497
  "function" => "getIterator"
  "class" => "Doctrine\Common\Collections\AbstractLazyCollection"
]
6 => array:4 [▼
  "file" => "C:\wamp64\www\vCheck\vendor\graphaware
eo4j-php-ogm\src\UnitOfWork.php"
  "line" => 150
  "function" => "traverseRelationshipEntities"
  "class" => "GraphAware\Neo4j\OGM\UnitOfWork"
]
7 => array:4 [▼
  "file" => "C:\wamp64\www\vCheck\vendor\graphaware
eo4j-php-ogm\src\UnitOfWork.php"
  "line" => 501
  "function" => "doPersist"
  "class" => "GraphAware\Neo4j\OGM\UnitOfWork"
]
8 => array:4 [▼
  "file" => "C:\wamp64\www\vCheck\vendor\graphaware
eo4j-php-ogm\src\UnitOfWork.php"
  "line" => 150
  "function" => "traverseRelationshipEntities"
  "class" => "GraphAware\Neo4j\OGM\UnitOfWork"
]
9 => array:4 [▼
  "file" => "C:\wamp64\www\vCheck\vendor\graphaware
eo4j-php-ogm\src\UnitOfWork.php"
  "line" => 123
  "function" => "doPersist"
  "class" => "GraphAware\Neo4j\OGM\UnitOfWork"
]
10 => array:4 [▼
  "file" => "C:\wamp64\www\vCheck\vendor\graphaware
eo4j-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"
]

Someone know solve this?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 2020长安杯与连接网探
    • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
    • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
    • ¥16 mybatis的代理对象无法通过@Autowired装填
    • ¥15 可见光定位matlab仿真
    • ¥15 arduino 四自由度机械臂
    • ¥15 wordpress 产品图片 GIF 没法显示
    • ¥15 求三国群英传pl国战时间的修改方法
    • ¥15 matlab代码代写,需写出详细代码,代价私
    • ¥15 ROS系统搭建请教(跨境电商用途)