{"id":16006,"date":"2013-08-07T22:00:19","date_gmt":"2013-08-07T19:00:19","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/?p=16006"},"modified":"2013-08-08T01:28:51","modified_gmt":"2013-08-07T22:28:51","slug":"neo4jcypher-getting-the-hang-of-query-parameters","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2013\/08\/neo4jcypher-getting-the-hang-of-query-parameters.html","title":{"rendered":"neo4j\/cypher: Getting the hang of query parameters"},"content":{"rendered":"<p>For as long as I\u2019ve been using <a href=\"http:\/\/www.neo4j.org\/\">neo4j<\/a>\u2018s <a href=\"http:\/\/www.neo4j.org\/learn\/cypher\">cypher<\/a> query language <a href=\"https:\/\/twitter.com\/mesirii\">Michael<\/a> has been telling me to use parameters in my queries but the performance of the queries was always acceptable so I didn\u2019t feel the need. However, recently I was playing around with a data set and I created ~500 nodes using code similar to this:<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<\/p>\n<pre class=\" brush:java\">require 'open-uri'\r\n\r\nopen(\"data\/people.cyp\", 'w') { |f|\r\n  (1..500).each do |value|\r\n    f.puts(\"CREATE (p:Person{name: \\\"#{value}\\\"})\")\r\n  end\r\n}<\/pre>\n<p>That creates a file of cypher statements that look like this:<\/p>\n<pre class=\" brush:java\">CREATE (:Person{name: \"person1\"})\r\nCREATE (:Person{name: \"person2\"})\r\nCREATE (:Person{name: \"person3\"})\r\nCREATE (:Person{name: \"person4\"})\r\nCREATE (:Person{name: \"person5\"})\r\n...<\/pre>\n<p>If we execute those statements in the neo4j-shell or web admin we get the following output:<\/p>\n<pre class=\" brush:bash\">==&gt; +-------------------+\r\n==&gt; | No data returned. |\r\n==&gt; +-------------------+\r\n==&gt; Nodes created: 500\r\n==&gt; Properties set: 500\r\n==&gt; Labels added: 500\r\n==&gt; 27706 ms<\/pre>\n<p>As far as I understand the reason it takes that long is that cypher creates and then caches a query plan for each create statement because it has no way of knowing that they are effectively the same. Since I was deleting\/reloading the data quite frequently I wanted to make my feedback loop a bit quicker so it was finally time to apply Michael\u2019s advice. The way that parameters work is that you add placeholders into your cypher queries and then provide values that should reify those placeholders when you execute your query. In this case it seemed easiest to make use of <a href=\"https:\/\/github.com\/maxdemarzi\/neography\">neography<\/a> to execute my query against a running neo4j server. If we want to create a single person with a parameterised name then we\u2019d write the following code:<\/p>\n<pre class=\" brush:java\">require 'neography'\r\n\r\nparams = { :name =&gt; \"Mark\" }\r\n\r\nNeography::Rest.new.execute_query(\"CREATE (:Person {name: {name} })\", params)<\/pre>\n<p>If we run a query to get back all people we can see they\u2019ve been successfully created:<\/p>\n<pre class=\" brush:bash\">neo4j-sh (0)$ match p:Person return p;\r\n==&gt; +----------------------+\r\n==&gt; | p                    |\r\n==&gt; +----------------------+\r\n==&gt; | Node[1]{name:\"Mark\"} |\r\n==&gt; +----------------------+\r\n==&gt; 1 row\r\n==&gt; 175 ms<\/pre>\n<p>I wanted to pass in an array of names which I initially thought I could do but changing the value in the <cite>params<\/cite> hash to an array:<\/p>\n<pre class=\" brush:java\">require 'neography'\r\n\r\nparams = { :name =&gt; [] }\r\n(1..500).each do |value|\r\n  params[:name] &lt;&lt; \"person#{value}\"\r\nend\r\n\r\nNeography::Rest.new.execute_query(\"CREATE (:Person {name: {name} })\", params)<\/pre>\n<p>I ran a query to get back my 500 people but only got one back:<\/p>\n<pre class=\"brush:bash; wrap-lines: false;\">neo4j-sh (0)$ MATCH p:Person RETURN p\r\n&gt; ;\r\n==&gt; +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\r\n==&gt; | p                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |\r\n==&gt; +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\r\n==&gt; | Node[1]{name:[\"person1\",\"person2\",\"person3\",\"person4\",\"person5\",\"person6\",\"person7\",\"person8\",\"person9\",\"person10\",\"person11\",\"person12\",\"person13\",\"person14\",\"person15\",\"person16\",\"person17\",\"person18\",\"person19\",\"person20\",\"person21\",\"person22\",\"person23\",\"person24\",\"person25\",\"person26\",\"person27\",\"person28\",\"person29\",\"person30\",\"person31\",\"person32\",\"person33\",\"person34\",\"person35\",\"person36\",\"person37\",\"person38\",\"person39\",\"person40\",\"person41\",\"person42\",\"person43\",\"person44\",\"person45\",\"person46\",\"person47\",\"person48\",\"person49\",\"person50\",\"person51\",\"person52\",\"person53\",\"person54\",\"person55\",\"person56\",\"person57\",\"person58\",\"person59\",\"person60\",\"person61\",\"person62\",\"person63\",\"person64\",\"person65\",\"person66\",\"person67\",\"person68\",\"person69\",\"person70\",\"person71\",\"person72\",\"person73\",\"person74\",\"person75\",\"person76\",\"person77\",\"person78\",\"person79\",\"person80\",\"person81\",\"person82\",\"person83\",\"person84\",\"person85\",\"person86\",\"person87\",\"person88\",\"person89\",\"person90\",\"person91\",\"person92\",\"person93\",\"person94\",\"person95\",\"person96\",\"person97\",\"person98\",\"person99\",\"person100\",\"person101\",\"person102\",\"person103\",\"person104\",\"person105\",\"person106\",\"person107\",\"person108\",\"person109\",\"person110\",\"person111\",\"person112\",\"person113\",\"person114\",\"person115\",\"person116\",\"person117\",\"person118\",\"person119\",\"person120\",\"person121\",\"person122\",\"person123\",\"person124\",\"person125\",\"person126\",\"person127\",\"person128\",\"person129\",\"person130\",\"person131\",\"person132\",\"person133\",\"person134\",\"person135\",\"person136\",\"person137\",\"person138\",\"person139\",\"person140\",\"person141\",\"person142\",\"person143\",\"person144\",\"person145\",\"person146\",\"person147\",\"person148\",\"person149\",\"person150\",\"person151\",\"person152\",\"person153\",\"person154\",\"person155\",\"person156\",\"person157\",\"person158\",\"person159\",\"person160\",\"person161\",\"person162\",\"person163\",\"person164\",\"person165\",\"person166\",\"person167\",\"person168\",\"person169\",\"person170\",\"person171\",\"person172\",\"person173\",\"person174\",\"person175\",\"person176\",\"person177\",\"person178\",\"person179\",\"person180\",\"person181\",\"person182\",\"person183\",\"person184\",\"person185\",\"person186\",\"person187\",\"person188\",\"person189\",\"person190\",\"person191\",\"person192\",\"person193\",\"person194\",\"person195\",\"person196\",\"person197\",\"person198\",\"person199\",\"person200\",\"person201\",\"person202\",\"person203\",\"person204\",\"person205\",\"person206\",\"person207\",\"person208\",\"person209\",\"person210\",\"person211\",\"person212\",\"person213\",\"person214\",\"person215\",\"person216\",\"person217\",\"person218\",\"person219\",\"person220\",\"person221\",\"person222\",\"person223\",\"person224\",\"person225\",\"person226\",\"person227\",\"person228\",\"person229\",\"person230\",\"person231\",\"person232\",\"person233\",\"person234\",\"person235\",\"person236\",\"person237\",\"person238\",\"person239\",\"person240\",\"person241\",\"person242\",\"person243\",\"person244\",\"person245\",\"person246\",\"person247\",\"person248\",\"person249\",\"person250\",\"person251\",\"person252\",\"person253\",\"person254\",\"person255\",\"person256\",\"person257\",\"person258\",\"person259\",\"person260\",\"person261\",\"person262\",\"person263\",\"person264\",\"person265\",\"person266\",\"person267\",\"person268\",\"person269\",\"person270\",\"person271\",\"person272\",\"person273\",\"person274\",\"person275\",\"person276\",\"person277\",\"person278\",\"person279\",\"person280\",\"person281\",\"person282\",\"person283\",\"person284\",\"person285\",\"person286\",\"person287\",\"person288\",\"person289\",\"person290\",\"person291\",\"person292\",\"person293\",\"person294\",\"person295\",\"person296\",\"person297\",\"person298\",\"person299\",\"person300\",\"person301\",\"person302\",\"person303\",\"person304\",\"person305\",\"person306\",\"person307\",\"person308\",\"person309\",\"person310\",\"person311\",\"person312\",\"person313\",\"person314\",\"person315\",\"person316\",\"person317\",\"person318\",\"person319\",\"person320\",\"person321\",\"person322\",\"person323\",\"person324\",\"person325\",\"person326\",\"person327\",\"person328\",\"person329\",\"person330\",\"person331\",\"person332\",\"person333\",\"person334\",\"person335\",\"person336\",\"person337\",\"person338\",\"person339\",\"person340\",\"person341\",\"person342\",\"person343\",\"person344\",\"person345\",\"person346\",\"person347\",\"person348\",\"person349\",\"person350\",\"person351\",\"person352\",\"person353\",\"person354\",\"person355\",\"person356\",\"person357\",\"person358\",\"person359\",\"person360\",\"person361\",\"person362\",\"person363\",\"person364\",\"person365\",\"person366\",\"person367\",\"person368\",\"person369\",\"person370\",\"person371\",\"person372\",\"person373\",\"person374\",\"person375\",\"person376\",\"person377\",\"person378\",\"person379\",\"person380\",\"person381\",\"person382\",\"person383\",\"person384\",\"person385\",\"person386\",\"person387\",\"person388\",\"person389\",\"person390\",\"person391\",\"person392\",\"person393\",\"person394\",\"person395\",\"person396\",\"person397\",\"person398\",\"person399\",\"person400\",\"person401\",\"person402\",\"person403\",\"person404\",\"person405\",\"person406\",\"person407\",\"person408\",\"person409\",\"person410\",\"person411\",\"person412\",\"person413\",\"person414\",\"person415\",\"person416\",\"person417\",\"person418\",\"person419\",\"person420\",\"person421\",\"person422\",\"person423\",\"person424\",\"person425\",\"person426\",\"person427\",\"person428\",\"person429\",\"person430\",\"person431\",\"person432\",\"person433\",\"person434\",\"person435\",\"person436\",\"person437\",\"person438\",\"person439\",\"person440\",\"person441\",\"person442\",\"person443\",\"person444\",\"person445\",\"person446\",\"person447\",\"person448\",\"person449\",\"person450\",\"person451\",\"person452\",\"person453\",\"person454\",\"person455\",\"person456\",\"person457\",\"person458\",\"person459\",\"person460\",\"person461\",\"person462\",\"person463\",\"person464\",\"person465\",\"person466\",\"person467\",\"person468\",\"person469\",\"person470\",\"person471\",\"person472\",\"person473\",\"person474\",\"person475\",\"person476\",\"person477\",\"person478\",\"person479\",\"person480\",\"person481\",\"person482\",\"person483\",\"person484\",\"person485\",\"person486\",\"person487\",\"person488\",\"person489\",\"person490\",\"person491\",\"person492\",\"person493\",\"person494\",\"person495\",\"person496\",\"person497\",\"person498\",\"person499\",\"person500\"]} |\r\n==&gt; +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\r\n==&gt; 1 row<\/pre>\n<p>I\u2019d actually made use of parameters in such a way that only one person got created and had their \u2018name\u2019 property set to an array of 500 names! I tweaked the code to pass in <a href=\"http:\/\/docs.neo4j.org\/chunked\/snapshot\/query-create.html#create-create-multiple-nodes-from-map\">an array of maps<\/a> instead of strings like so:<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<pre class=\" brush:java\">require 'neography'\r\n\r\nparams = { :people =&gt; [] }\r\n(1..500).each do |value|\r\n  params[:people] &lt;&lt; { :name =&gt; \"person#{value}\"}\r\nend\r\n\r\nNeography::Rest.new.execute_query(\"CREATE (:Person {people})\", params)<\/pre>\n<p>I ran my script to populate the database before querying it again:<\/p>\n<pre class=\" brush:java\">neo4j-sh (0)$ MATCH p:Person RETURN p;\r\n==&gt; +-----------------------------+\r\n==&gt; | p                           |\r\n==&gt; +-----------------------------+\r\n==&gt; | Node[1]{name:\"person1\"}     |\r\n==&gt; | Node[2]{name:\"person2\"}     |\r\n==&gt; | Node[3]{name:\"person3\"}     |\r\n==&gt; | Node[4]{name:\"person4\"}     |\r\n==&gt; | Node[5]{name:\"person5\"}     |\r\n==&gt; | Node[6]{name:\"person6\"}     |\r\n==&gt; | Node[7]{name:\"person7\"}     |\r\n==&gt; | Node[8]{name:\"person8\"}     |\r\n==&gt; | Node[9]{name:\"person9\"}     |\r\n==&gt; | Node[10]{name:\"person10\"}   |\r\n==&gt; | Node[11]{name:\"person11\"}   |\r\n...\r\n==&gt; +-----------------------------+\r\n==&gt; 500 rows\r\n==&gt; 1081 ms<\/pre>\n<p>This time I got the expected result so the only thing to do was to quickly check how long it had taken to get the parameterised data into the database:<\/p>\n<pre class=\" brush:bash\">$ time bundle exec ruby people.rb \r\n\r\nreal\t0m0.993s\r\nuser\t0m0.733s\r\nsys\t0m0.097s<\/pre>\n<p>And the winner is\u2026Michael, by about 26 seconds per run. <\/p>\n<p>In this version cypher creates a query plan the first time it encounters the CREATE statement but after that it can use the query plan for the subsequent calls which leads to a massive performance improvement.<\/p>\n<p><a href=\"http:\/\/www.apcjones.com\/blog\/\">Alistair<\/a> pointed out that the query parameter approach is quite nice when used in applications because you don\u2019t need to worry about string concatenation, you can just change values in maps instead. <\/p>\n<p>Based on this experience I can now confirm <a href=\"https:\/\/twitter.com\/maxdemarzi\">Max De Marzi<\/a>\u2018s tweet from last week: <\/p>\n<blockquote>\n<p><i> Public Service Announcement for folks new to @<a href=\"https:\/\/twitter.com\/neo4j\">neo4j<\/a> and Cypher: Please use parameters in your queries <a href=\"http:\/\/docs.neo4j.org\/chunked\/milestone\/cypher-parameters.html\">http:\/\/docs.neo4j.org\/chunked\/milestone\/cypher-parameters.html<\/a> #MuchFaster<\/i><\/p>\n<\/blockquote>\n<p>&nbsp;<\/p>\n<div style=\"border: 1px solid #D8D8D8; background: #FAFAFA; width: 100%; padding-left: 5px;\"><b><i>Reference: <\/i><\/b><a href=\"http:\/\/www.markhneedham.com\/blog\/2013\/07\/27\/neo4jcypher-getting-the-hang-of-query-parameters\/\">neo4j\/cypher: Getting the hang of query parameters<\/a> from our <a href=\"http:\/\/www.javacodegeeks.com\/jcg\">JCG partner<\/a> Mark Needham at the <a href=\"http:\/\/www.markhneedham.com\/blog\/\">Mark Needham Blog<\/a> blog.<\/div>\n","protected":false},"excerpt":{"rendered":"<p>For as long as I\u2019ve been using neo4j\u2018s cypher query language Michael has been telling me to use parameters in my queries but the performance of the queries was always acceptable so I didn\u2019t feel the need. However, recently I was playing around with a data set and I created ~500 nodes using code similar &hellip;<\/p>\n","protected":false},"author":134,"featured_media":191,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[349],"class_list":["post-16006","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-neo4j"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>neo4j\/cypher: Getting the hang of query parameters<\/title>\n<meta name=\"description\" content=\"For as long as I\u2019ve been using neo4j\u2018s cypher query language Michael has been telling me to use parameters in my queries but the performance of the\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2013\/08\/neo4jcypher-getting-the-hang-of-query-parameters.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"neo4j\/cypher: Getting the hang of query parameters\" \/>\n<meta property=\"og:description\" content=\"For as long as I\u2019ve been using neo4j\u2018s cypher query language Michael has been telling me to use parameters in my queries but the performance of the\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2013\/08\/neo4jcypher-getting-the-hang-of-query-parameters.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2013-08-07T19:00:19+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2013-08-07T22:28:51+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/neo4j-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Mark Needham\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Mark Needham\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/08\\\/neo4jcypher-getting-the-hang-of-query-parameters.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/08\\\/neo4jcypher-getting-the-hang-of-query-parameters.html\"},\"author\":{\"name\":\"Mark Needham\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/fdb35381baa5059768d6788cfb685313\"},\"headline\":\"neo4j\\\/cypher: Getting the hang of query parameters\",\"datePublished\":\"2013-08-07T19:00:19+00:00\",\"dateModified\":\"2013-08-07T22:28:51+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/08\\\/neo4jcypher-getting-the-hang-of-query-parameters.html\"},\"wordCount\":529,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/08\\\/neo4jcypher-getting-the-hang-of-query-parameters.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/neo4j-logo.jpg\",\"keywords\":[\"Neo4j\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/08\\\/neo4jcypher-getting-the-hang-of-query-parameters.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/08\\\/neo4jcypher-getting-the-hang-of-query-parameters.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/08\\\/neo4jcypher-getting-the-hang-of-query-parameters.html\",\"name\":\"neo4j\\\/cypher: Getting the hang of query parameters\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/08\\\/neo4jcypher-getting-the-hang-of-query-parameters.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/08\\\/neo4jcypher-getting-the-hang-of-query-parameters.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/neo4j-logo.jpg\",\"datePublished\":\"2013-08-07T19:00:19+00:00\",\"dateModified\":\"2013-08-07T22:28:51+00:00\",\"description\":\"For as long as I\u2019ve been using neo4j\u2018s cypher query language Michael has been telling me to use parameters in my queries but the performance of the\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/08\\\/neo4jcypher-getting-the-hang-of-query-parameters.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/08\\\/neo4jcypher-getting-the-hang-of-query-parameters.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/08\\\/neo4jcypher-getting-the-hang-of-query-parameters.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/neo4j-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/neo4j-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/08\\\/neo4jcypher-getting-the-hang-of-query-parameters.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"neo4j\\\/cypher: Getting the hang of query parameters\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/fdb35381baa5059768d6788cfb685313\",\"name\":\"Mark Needham\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5489baed26ce2d932bf951ecfb47afe80bec45d3648c23521d87c83b8f1c3ea9?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5489baed26ce2d932bf951ecfb47afe80bec45d3648c23521d87c83b8f1c3ea9?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5489baed26ce2d932bf951ecfb47afe80bec45d3648c23521d87c83b8f1c3ea9?s=96&d=mm&r=g\",\"caption\":\"Mark Needham\"},\"sameAs\":[\"http:\\\/\\\/www.markhneedham.com\\\/blog\\\/\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/Mark-Needham\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"neo4j\/cypher: Getting the hang of query parameters","description":"For as long as I\u2019ve been using neo4j\u2018s cypher query language Michael has been telling me to use parameters in my queries but the performance of the","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2013\/08\/neo4jcypher-getting-the-hang-of-query-parameters.html","og_locale":"en_US","og_type":"article","og_title":"neo4j\/cypher: Getting the hang of query parameters","og_description":"For as long as I\u2019ve been using neo4j\u2018s cypher query language Michael has been telling me to use parameters in my queries but the performance of the","og_url":"https:\/\/www.javacodegeeks.com\/2013\/08\/neo4jcypher-getting-the-hang-of-query-parameters.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2013-08-07T19:00:19+00:00","article_modified_time":"2013-08-07T22:28:51+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/neo4j-logo.jpg","type":"image\/jpeg"}],"author":"Mark Needham","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Mark Needham","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2013\/08\/neo4jcypher-getting-the-hang-of-query-parameters.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/08\/neo4jcypher-getting-the-hang-of-query-parameters.html"},"author":{"name":"Mark Needham","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/fdb35381baa5059768d6788cfb685313"},"headline":"neo4j\/cypher: Getting the hang of query parameters","datePublished":"2013-08-07T19:00:19+00:00","dateModified":"2013-08-07T22:28:51+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/08\/neo4jcypher-getting-the-hang-of-query-parameters.html"},"wordCount":529,"commentCount":0,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/08\/neo4jcypher-getting-the-hang-of-query-parameters.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/neo4j-logo.jpg","keywords":["Neo4j"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2013\/08\/neo4jcypher-getting-the-hang-of-query-parameters.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2013\/08\/neo4jcypher-getting-the-hang-of-query-parameters.html","url":"https:\/\/www.javacodegeeks.com\/2013\/08\/neo4jcypher-getting-the-hang-of-query-parameters.html","name":"neo4j\/cypher: Getting the hang of query parameters","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/08\/neo4jcypher-getting-the-hang-of-query-parameters.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/08\/neo4jcypher-getting-the-hang-of-query-parameters.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/neo4j-logo.jpg","datePublished":"2013-08-07T19:00:19+00:00","dateModified":"2013-08-07T22:28:51+00:00","description":"For as long as I\u2019ve been using neo4j\u2018s cypher query language Michael has been telling me to use parameters in my queries but the performance of the","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/08\/neo4jcypher-getting-the-hang-of-query-parameters.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2013\/08\/neo4jcypher-getting-the-hang-of-query-parameters.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2013\/08\/neo4jcypher-getting-the-hang-of-query-parameters.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/neo4j-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/neo4j-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2013\/08\/neo4jcypher-getting-the-hang-of-query-parameters.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"neo4j\/cypher: Getting the hang of query parameters"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/fdb35381baa5059768d6788cfb685313","name":"Mark Needham","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/5489baed26ce2d932bf951ecfb47afe80bec45d3648c23521d87c83b8f1c3ea9?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/5489baed26ce2d932bf951ecfb47afe80bec45d3648c23521d87c83b8f1c3ea9?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/5489baed26ce2d932bf951ecfb47afe80bec45d3648c23521d87c83b8f1c3ea9?s=96&d=mm&r=g","caption":"Mark Needham"},"sameAs":["http:\/\/www.markhneedham.com\/blog\/"],"url":"https:\/\/www.javacodegeeks.com\/author\/Mark-Needham"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/16006","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/134"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=16006"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/16006\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/191"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=16006"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=16006"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=16006"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}