{"action":"created","issue":{"url":"https://api.github.com/repos/neo4j/neo4j-ogm/issues/59","labels_url":"https://api.github.com/repos/neo4j/neo4j-ogm/issues/59/labels{/name}","comments_url":"https://api.github.com/repos/neo4j/neo4j-ogm/issues/59/comments","events_url":"https://api.github.com/repos/neo4j/neo4j-ogm/issues/59/events","html_url":"https://github.com/neo4j/neo4j-ogm/issues/59","id":109668380,"number":59,"title":"When generating queries, make sure to reuse the same pattern","user":{"login":"jexp","id":67427,"avatar_url":"https://avatars.githubusercontent.com/u/67427?v=3","gravatar_id":"","url":"https://api.github.com/users/jexp","html_url":"https://github.com/jexp","followers_url":"https://api.github.com/users/jexp/followers","following_url":"https://api.github.com/users/jexp/following{/other_user}","gists_url":"https://api.github.com/users/jexp/gists{/gist_id}","starred_url":"https://api.github.com/users/jexp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jexp/subscriptions","organizations_url":"https://api.github.com/users/jexp/orgs","repos_url":"https://api.github.com/users/jexp/repos","events_url":"https://api.github.com/users/jexp/events{/privacy}","received_events_url":"https://api.github.com/users/jexp/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/neo4j/neo4j-ogm/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-04T07:52:18Z","updated_at":"2015-12-10T15:26:49Z","closed_at":"2015-12-10T15:26:49Z","body":"Currently queries are generated with new identifiers all the time.\r\n\r\nMake sure that we reuse the same identifiers across queries so that the same query pattern is always the same, utilizing the query cache of Cypher.\r\n\r\ne.g. this\r\n\r\n```\r\nMATCH ($47457) WHERE id($47457)={$47457} \r\nMATCH ($47516) WHERE id($47516)={$47516} \r\nMERGE ($47457)-[_49:`RelationshipAB`{propertyAB:{_49_props}.propertyAB}]->($47516) \r\nRETURN id(_49) AS _49\r\n```\r\n\r\nmust rather be:\r\n\r\n```\r\nMATCH (a) WHERE id(a)={id_a} \r\nMATCH (b) WHERE id(b)={id_b} \r\nMERGE (a)-[r:`RelationshipAB`{propertyAB:{props_r}.propertyAB}]->(b) \r\nRETURN id(r) AS id_r\r\n```\r\n\r\nIf necessary, the entity-type could be part of the identifiers.\r\n\r\nThe latter can even be:\r\n```\r\nMATCH (a) WHERE id(a)={id_a} \r\nMATCH (b) WHERE id(b)={id_b} \r\nMERGE (a)-[r:`RelationshipAB`]->(b) \r\nON CREATE SET r = {props_r}\r\nRETURN id(r) AS id_r\r\n```"},"comment":{"url":"https://api.github.com/repos/neo4j/neo4j-ogm/issues/comments/163658194","html_url":"https://github.com/neo4j/neo4j-ogm/issues/59#issuecomment-163658194","issue_url":"https://api.github.com/repos/neo4j/neo4j-ogm/issues/59","id":163658194,"user":{"login":"luanne","id":1242476,"avatar_url":"https://avatars.githubusercontent.com/u/1242476?v=3","gravatar_id":"","url":"https://api.github.com/users/luanne","html_url":"https://github.com/luanne","followers_url":"https://api.github.com/users/luanne/followers","following_url":"https://api.github.com/users/luanne/following{/other_user}","gists_url":"https://api.github.com/users/luanne/gists{/gist_id}","starred_url":"https://api.github.com/users/luanne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luanne/subscriptions","organizations_url":"https://api.github.com/users/luanne/orgs","repos_url":"https://api.github.com/users/luanne/repos","events_url":"https://api.github.com/users/luanne/events{/privacy}","received_events_url":"https://api.github.com/users/luanne/received_events","type":"User","site_admin":false},"created_at":"2015-12-10T15:26:49Z","updated_at":"2015-12-10T15:26:49Z","body":"Will be released with OGM 2.0"}}