{"id":2155,"date":"2016-02-04T21:19:09","date_gmt":"2016-02-04T21:19:09","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/?p=2155"},"modified":"2025-06-13T20:20:34","modified_gmt":"2025-06-14T03:20:34","slug":"prepared-statements-in-couchbase-by-the-numbers","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/prepared-statements-in-couchbase-by-the-numbers\/","title":{"rendered":"Prepared Statements &#8211; by the Numbers!"},"content":{"rendered":"<h2><img decoding=\"async\" src=\"\/wp-content\/original-assets\/2016\/february\/prepared-statements-in-couchbase-by-the-numbers\/f_psb.jpg\" \/><\/h2>\n<h2>Always be Prepared&#8230;.<\/h2>\n<p>In our last <a href=\"https:\/\/www.couchbase.com\/blog\/prepare-for-performance\/\">discussion<\/a> on prepared statements in couchbase we talked about the performance gains that are possible using prepared statements. I thought I&#8217;d post a &#8220;sequel&#8221; with a few real world examples and numbers using the included travel-sample dataset that ships with Couchbase.<\/p>\n<h2>A Simple Analysis<\/h2>\n<p>In the gist below, I used a simple control loop to simulate load against couchbase running on my laptop. I examined the performance of various queries: some with parameterization, different predicate strategies, joins, and a mixture of indexed and non indexed fields. The results are impressive, and proved to me there are substantial gains to be made by using prepared statements in most cases. We&#8217;re still prisoners to the laws of physics when things like full primary index scans are required to return results, but in <strong>most<\/strong> situations prepared statements should be used to where-ever possible to increase performance.<\/p>\n<p><script src=\"https:\/\/gist.github.com\/ToddGreenstein\/2763705341dd317240e3.js\"><\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Always be Prepared&#8230;. In our last discussion on prepared statements in couchbase we talked about the performance gains that are possible using prepared statements. I thought I&#8217;d post a &#8220;sequel&#8221; with a few real world examples and numbers using the [&hellip;]<\/p>\n","protected":false},"author":20,"featured_media":13873,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[9417,1822,1812],"tags":[],"ppma_author":[9019],"class_list":["post-2155","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-performance","category-node-js","category-n1ql-query"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.3 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Prepared Statements - by the Numbers! - The Couchbase Blog<\/title>\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.couchbase.com\/blog\/prepared-statements-in-couchbase-by-the-numbers\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Prepared Statements - by the Numbers!\" \/>\n<meta property=\"og:description\" content=\"Always be Prepared&#8230;. In our last discussion on prepared statements in couchbase we talked about the performance gains that are possible using prepared statements. I thought I&#8217;d post a &#8220;sequel&#8221; with a few real world examples and numbers using the [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/prepared-statements-in-couchbase-by-the-numbers\/\" \/>\n<meta property=\"og:site_name\" content=\"The Couchbase Blog\" \/>\n<meta property=\"article:published_time\" content=\"2016-02-04T21:19:09+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-14T03:20:34+00:00\" \/>\n<meta name=\"author\" content=\"Todd Greenstein\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@todd_greenstein\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Todd Greenstein\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/prepared-statements-in-couchbase-by-the-numbers\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/prepared-statements-in-couchbase-by-the-numbers\\\/\"},\"author\":{\"name\":\"Todd Greenstein\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/person\\\/64b5d1e5969768c5d63c11c696951ed3\"},\"headline\":\"Prepared Statements &#8211; by the Numbers!\",\"datePublished\":\"2016-02-04T21:19:09+00:00\",\"dateModified\":\"2025-06-14T03:20:34+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/prepared-statements-in-couchbase-by-the-numbers\\\/\"},\"wordCount\":157,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/prepared-statements-in-couchbase-by-the-numbers\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/1\\\/2022\\\/11\\\/couchbase-nosql-dbaas.png\",\"articleSection\":[\"High Performance\",\"Node.js\",\"SQL++ \\\/ N1QL Query\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/prepared-statements-in-couchbase-by-the-numbers\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/prepared-statements-in-couchbase-by-the-numbers\\\/\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/prepared-statements-in-couchbase-by-the-numbers\\\/\",\"name\":\"Prepared Statements - by the Numbers! - The Couchbase Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/prepared-statements-in-couchbase-by-the-numbers\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/prepared-statements-in-couchbase-by-the-numbers\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/1\\\/2022\\\/11\\\/couchbase-nosql-dbaas.png\",\"datePublished\":\"2016-02-04T21:19:09+00:00\",\"dateModified\":\"2025-06-14T03:20:34+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/prepared-statements-in-couchbase-by-the-numbers\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/prepared-statements-in-couchbase-by-the-numbers\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/prepared-statements-in-couchbase-by-the-numbers\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/1\\\/2022\\\/11\\\/couchbase-nosql-dbaas.png\",\"contentUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/1\\\/2022\\\/11\\\/couchbase-nosql-dbaas.png\",\"width\":1800,\"height\":630},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/prepared-statements-in-couchbase-by-the-numbers\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Prepared Statements &#8211; by the Numbers!\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/\",\"name\":\"The Couchbase Blog\",\"description\":\"Couchbase, the NoSQL Database\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#organization\",\"name\":\"The Couchbase Blog\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/04\\\/admin-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/04\\\/admin-logo.png\",\"width\":218,\"height\":34,\"caption\":\"The Couchbase Blog\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/person\\\/64b5d1e5969768c5d63c11c696951ed3\",\"name\":\"Todd Greenstein\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f230045f7f6e636cf01abbd35f1cbf66a1206fbe149a0d4f0bbdd992c646257d?s=96&d=mm&r=gabfbe093983052aa28595343c19888ce\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f230045f7f6e636cf01abbd35f1cbf66a1206fbe149a0d4f0bbdd992c646257d?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f230045f7f6e636cf01abbd35f1cbf66a1206fbe149a0d4f0bbdd992c646257d?s=96&d=mm&r=g\",\"caption\":\"Todd Greenstein\"},\"description\":\"Todd Greenstein is a Solution Architect at Couchbase. Todd is specialize in API design, architecture, data modeling, nodejs and golang development.\",\"sameAs\":[\"https:\\\/\\\/x.com\\\/todd_greenstein\"],\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/author\\\/todd-greenstein\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Prepared Statements - by the Numbers! - The Couchbase Blog","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.couchbase.com\/blog\/prepared-statements-in-couchbase-by-the-numbers\/","og_locale":"en_US","og_type":"article","og_title":"Prepared Statements - by the Numbers!","og_description":"Always be Prepared&#8230;. In our last discussion on prepared statements in couchbase we talked about the performance gains that are possible using prepared statements. I thought I&#8217;d post a &#8220;sequel&#8221; with a few real world examples and numbers using the [&hellip;]","og_url":"https:\/\/www.couchbase.com\/blog\/prepared-statements-in-couchbase-by-the-numbers\/","og_site_name":"The Couchbase Blog","article_published_time":"2016-02-04T21:19:09+00:00","article_modified_time":"2025-06-14T03:20:34+00:00","author":"Todd Greenstein","twitter_card":"summary_large_image","twitter_creator":"@todd_greenstein","twitter_misc":{"Written by":"Todd Greenstein","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.couchbase.com\/blog\/prepared-statements-in-couchbase-by-the-numbers\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/prepared-statements-in-couchbase-by-the-numbers\/"},"author":{"name":"Todd Greenstein","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/64b5d1e5969768c5d63c11c696951ed3"},"headline":"Prepared Statements &#8211; by the Numbers!","datePublished":"2016-02-04T21:19:09+00:00","dateModified":"2025-06-14T03:20:34+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/prepared-statements-in-couchbase-by-the-numbers\/"},"wordCount":157,"commentCount":0,"publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/prepared-statements-in-couchbase-by-the-numbers\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","articleSection":["High Performance","Node.js","SQL++ \/ N1QL Query"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/blog\/prepared-statements-in-couchbase-by-the-numbers\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/prepared-statements-in-couchbase-by-the-numbers\/","url":"https:\/\/www.couchbase.com\/blog\/prepared-statements-in-couchbase-by-the-numbers\/","name":"Prepared Statements - by the Numbers! - The Couchbase Blog","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/prepared-statements-in-couchbase-by-the-numbers\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/prepared-statements-in-couchbase-by-the-numbers\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","datePublished":"2016-02-04T21:19:09+00:00","dateModified":"2025-06-14T03:20:34+00:00","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/prepared-statements-in-couchbase-by-the-numbers\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/prepared-statements-in-couchbase-by-the-numbers\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/prepared-statements-in-couchbase-by-the-numbers\/#primaryimage","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","width":1800,"height":630},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/blog\/prepared-statements-in-couchbase-by-the-numbers\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Prepared Statements &#8211; by the Numbers!"}]},{"@type":"WebSite","@id":"https:\/\/www.couchbase.com\/blog\/#website","url":"https:\/\/www.couchbase.com\/blog\/","name":"The Couchbase Blog","description":"Couchbase, the NoSQL Database","publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.couchbase.com\/blog\/#organization","name":"The Couchbase Blog","url":"https:\/\/www.couchbase.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","width":218,"height":34,"caption":"The Couchbase Blog"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/64b5d1e5969768c5d63c11c696951ed3","name":"Todd Greenstein","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/f230045f7f6e636cf01abbd35f1cbf66a1206fbe149a0d4f0bbdd992c646257d?s=96&d=mm&r=gabfbe093983052aa28595343c19888ce","url":"https:\/\/secure.gravatar.com\/avatar\/f230045f7f6e636cf01abbd35f1cbf66a1206fbe149a0d4f0bbdd992c646257d?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f230045f7f6e636cf01abbd35f1cbf66a1206fbe149a0d4f0bbdd992c646257d?s=96&d=mm&r=g","caption":"Todd Greenstein"},"description":"Todd Greenstein is a Solution Architect at Couchbase. Todd is specialize in API design, architecture, data modeling, nodejs and golang development.","sameAs":["https:\/\/x.com\/todd_greenstein"],"url":"https:\/\/www.couchbase.com\/blog\/author\/todd-greenstein\/"}]}},"acf":[],"authors":[{"term_id":9019,"user_id":20,"is_guest":0,"slug":"todd-greenstein","display_name":"Todd Greenstein","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/f230045f7f6e636cf01abbd35f1cbf66a1206fbe149a0d4f0bbdd992c646257d?s=96&d=mm&r=g","0":null,"1":"","2":"","3":"","4":"","5":"","6":"","7":"","8":""}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/2155","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/users\/20"}],"replies":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/comments?post=2155"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/2155\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media\/13873"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media?parent=2155"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/categories?post=2155"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/tags?post=2155"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=2155"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}