{"id":9439,"date":"2020-10-14T12:45:47","date_gmt":"2020-10-14T19:45:47","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/?p=9439"},"modified":"2025-06-13T18:44:03","modified_gmt":"2025-06-14T01:44:03","slug":"transactions-n1ql-couchbase-distributed-nosql","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/transactions-n1ql-couchbase-distributed-nosql\/","title":{"rendered":"N1QL Transactions : Elastic, Scalable, and Distributed"},"content":{"rendered":"<blockquote><p><span style=\"font-weight: 400;color: #0000ff\">SQL is the only 22nd-century language available for developers today.<\/span><\/p><\/blockquote>\n<p><strong>ABSTRACT<\/strong><\/p>\n<p><span style=\"font-weight: 400\">In relational database systems, SQL is more than a declarative query language. It includes procedural language (T-SQL, PL\/SQL, etc) and defines transactions and its semantics.\u00a0 SQL as a query language has been <\/span><span style=\"font-weight: 400\">unreasonably effective even in <\/span><a href=\"https:\/\/www.couchbase.com\/blog\/the-unreasonable-effectiveness-of-sql-in-nosql-databases\/\"><span style=\"font-weight: 400\">NoSQL database systems<\/span><\/a><span style=\"font-weight: 400\">. However, few NoSQL database systems support transactions.\u00a0 The ones that support come with a long list of limitations and\/or were unable to support SQL operations within the transaction.\u00a0 We introduce and explain transactions in Couchbase N1QL: SQL for JSON.\u00a0 N1QL transactions are multi-everything: multi-document, multi-bucket, multi-scope, multi collection, and multi-DML-statement.<\/span><\/p>\n<p>N1QL Transactions is available with Couchbase 7.0 Beta. You can download it here: <a href=\"https:\/\/www.couchbase.com\/downloads\/\">https:\/\/www.couchbase.com\/downloads<\/a>. See the documentation <a href=\"https:\/\/docs.couchbase.com\/server\/7.0\/introduction\/whats-new.html\">here<\/a>.<\/p>\n<p><strong>INTRODUCTION<\/strong><\/p>\n<p><a href=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2020\/10\/Screen-Shot-2020-10-13-at-5.46.18-PM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-9442\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2020\/10\/Screen-Shot-2020-10-13-at-5.46.18-PM-300x166.png\" alt=\"\" width=\"661\" height=\"366\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/10\/Screen-Shot-2020-10-13-at-5.46.18-PM-300x166.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/10\/Screen-Shot-2020-10-13-at-5.46.18-PM-1024x565.png 1024w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/10\/Screen-Shot-2020-10-13-at-5.46.18-PM-768x424.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/10\/Screen-Shot-2020-10-13-at-5.46.18-PM-20x11.png 20w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/10\/Screen-Shot-2020-10-13-at-5.46.18-PM-1320x729.png 1320w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/10\/Screen-Shot-2020-10-13-at-5.46.18-PM.png 1348w\" sizes=\"auto, (max-width: 661px) 100vw, 661px\" \/><\/a><a href=\"https:\/\/docs.couchbase.com\/server\/current\/n1ql\/n1ql-language-reference\/index.html\"><span style=\"font-weight: 400\">N1QL<\/span><\/a><span style=\"font-weight: 400\"> is<\/span><span style=\"font-weight: 400\">\u00a0a declarative language to manipulate JSON. Couchbase stores all the documents in the data service.\u00a0 The query service orchestrates the <\/span><a href=\"https:\/\/www.couchbase.com\/blog\/n1ql-query-basic-order-of-execution\/\"><span style=\"font-weight: 400\">query execution<\/span><\/a><span style=\"font-weight: 400\"> optimizing the query, creating an execution plan, and then executing it using data, indexing, and FTS.\u00a0 The <a href=\"https:\/\/docs.couchbase.com\/server\/current\/sdk\/overview.html\">Couchbase SDK<\/a> and query interaction protocol is built via REST over HTTP\/S.\u00a0 \u00a0N1QL DML statements include <a href=\"https:\/\/docs.couchbase.com\/server\/current\/n1ql\/n1ql-language-reference\/selectintro.html\">SELECT<\/a>, <a href=\"https:\/\/docs.couchbase.com\/server\/current\/n1ql\/n1ql-language-reference\/insert.html\">INSERT<\/a>, <a href=\"https:\/\/docs.couchbase.com\/server\/current\/n1ql\/n1ql-language-reference\/update.html\">UPDATE<\/a>, <a href=\"https:\/\/docs.couchbase.com\/server\/current\/n1ql\/n1ql-language-reference\/upsert.html\">UPSERT<\/a>, <a href=\"https:\/\/docs.couchbase.com\/server\/current\/n1ql\/n1ql-language-reference\/delete.html\">DELETE<\/a>, and <a href=\"https:\/\/docs.couchbase.com\/server\/current\/n1ql\/n1ql-language-reference\/merge.html\">MERGE<\/a>.\u00a0\u00a0<\/span><\/p>\n<p><strong>N1QL TRANSACTIONS<\/strong><\/p>\n<p>Here&#8217;s an example of transactions in RDBMS and Couchbase N1QL.<\/p>\n<div class=\"responsive-table\">\n<table width=\"800\">\n<tbody>\n<tr>\n<td width=\"150\">\n<h6><span style=\"color: #ff0000\"><strong>Transactions<\/strong><\/span><\/h6>\n<\/td>\n<td width=\"325\">\n<h6><span style=\"color: #0000ff\">MySQL Database (Statements are same\/similar in Oracle, SQL Server, Informix &amp; DB2)<\/span><\/h6>\n<\/td>\n<td width=\"325\">\n<h6><span style=\"color: #ff0000\"><strong>Couchbase Database (Cheshire-Cat)<\/strong><\/span><\/h6>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"150\">\n<h6>Insert data. Tuples in MySQL, JSON documents in Couchbase<\/h6>\n<\/td>\n<td width=\"325\">\n<h6>INSERT INTO customer(cid, name, balance) VALUES(4872, &#8220;John Doe&#8221;, 724.23);<\/h6>\n<h6>INSERT INTO customer(cid, name, balance) VALUES(1924, &#8220;Bob Stanton&#8221;, 2735.48);<\/h6>\n<\/td>\n<td width=\"325\">\n<h6>INSERT INTO customer<br \/>\nVALUES(&#8220;cx4872&#8221;, {&#8220;cid&#8221;: 4872, &#8220;name&#8221;:&#8221;John Doe&#8221;, &#8220;balance&#8221;:724.23});<\/h6>\n<h6>INSERT INTO customer<br \/>\nVALUES(&#8220;cx1924&#8221;, {&#8220;cid&#8221;: 1924, &#8220;name&#8221;:&#8221;Bob Stanton&#8221;, &#8220;balance&#8221;:2735.48});<\/h6>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"150\">\n<h6>Simple transaction, debit, and credit. Intermediate selects have to be read their own updates (RYOW)<\/h6>\n<\/td>\n<td width=\"325\">\n<h6><strong>START TRANSACTION;<\/strong><\/h6>\n<h6>UPDATE customer SET balance = balance + 100 WHERE cid = 4872;<\/h6>\n<h6>SELECT cid, name, balance\u00a0 from customer;<\/h6>\n<h6>UPDATE customer SET balance = balance &#8211; 100 WHERE cid = 1924;<\/h6>\n<h6>SELECT cid, name, balance from customer;<\/h6>\n<h6><strong>COMMIT ;<\/strong><\/h6>\n<\/td>\n<td width=\"325\">\n<h6><strong>START TRANSACTION;<\/strong><\/h6>\n<h6>UPDATE customer SET balance = balance + 100 WHERE cid = 4872;<\/h6>\n<h6>SELECT cid, name, balance\u00a0 from customer;<\/h6>\n<h6>UPDATE customer SET balance = balance &#8211; 100 WHERE cid = 1924;<\/h6>\n<h6>SELECT cid, name, balance from customer;<\/h6>\n<h6><strong>COMMIT ;<\/strong><\/h6>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"150\">\n<h6>The second transaction with partial rollback.<\/h6>\n<\/td>\n<td width=\"325\">\n<h6><strong>START TRANSACTION;<\/strong><\/h6>\n<h6>UPDATE customer SET balance = balance + 100 WHERE cid = 4872;<\/h6>\n<h6>SELECT cid, name, balance\u00a0 from customer;<\/h6>\n<h6><strong>SAVEPOINT s1;<\/strong><\/h6>\n<h6>UPDATE customer SET balance = balance &#8211; 100 WHERE cid = 1924;<\/h6>\n<h6>SELECT cid, name, balance from customer;<\/h6>\n<h6><strong>ROLLBACK WORK TO SAVEPOINT s1;<\/strong><\/h6>\n<h6>SELECT cid, name, balance from customer;<\/h6>\n<h6><strong>COMMIT ;<\/strong><\/h6>\n<\/td>\n<td width=\"325\">\n<h6><strong>START TRANSACTION;<\/strong><\/h6>\n<h6>UPDATE customer SET balance = balance + 100 WHERE cid = 4872;<\/h6>\n<h6>SELECT cid, name, balance\u00a0 from customer;<\/h6>\n<h6><strong>SAVEPOINT s1;<\/strong><\/h6>\n<h6>UPDATE customer SET balance = balance &#8211; 100 WHERE cid = 1924;<\/h6>\n<h6>SELECT cid, name, balance from customer;<\/h6>\n<h6><strong>ROLLBACK WORK TO SAVEPOINT s1;<\/strong><\/h6>\n<h6>SELECT cid, name, balance from customer;<\/h6>\n<h6><strong>COMMIT ;<\/strong><\/h6>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<blockquote><p><span style=\"color: #0000ff\">If you didn&#8217;t see much difference, that&#8217;s because, there isn&#8217;t.\u00a0<\/span><\/p><\/blockquote>\n<p><strong>N1QL TRANSACTIONS STATEMENTS<\/strong><\/p>\n<p>N1QL transactions a set of transactions that include any of the DML statements in all forms: <span style=\"color: #0000ff\">no restrictions<\/span>. Transactional protection is issued from new statements: <span style=\"color: #0000ff\">BEGIN\/START, COMMIT, ROLLBACK, SAVEPOINT<\/span>.<\/p>\n<h6><strong>START TRANSACTION\u00a0 (same as BEGIN WORK)<\/strong><\/h6>\n<p>This statement starts a new transaction, assigns a new transaction ID, and returns the transaction ID to the caller. There are two rules the SDKs, tools (e.g. CBQ shell) follow to successfully execute the rest of the transaction.<\/p>\n<ol>\n<li>Send this transaction ID as a parameter every subsequent statement within the transaction.\u00a0 This is how the query service knows the statement should be run as part of a particular transaction.<\/li>\n<li>Couchbase can have multiple query service nodes, but a single transaction is executed on a single query node. You can start a new transaction in ANY QUERY NODE. However, the rest of the statements FOR THAT SINGLE TRANSACTION should be sent to the VERY SAME query node.<\/li>\n<\/ol>\n<h6><strong>COMMIT TRANSACTION or COMMIT WORK;<\/strong><\/h6>\n<p>This commits all the changes in the transaction to the data store. This is a distributed commit of the transaction into the Couchbase key-value data store.\u00a0 The commit supports all of the <a href=\"https:\/\/docs.couchbase.com\/java-sdk\/current\/concept-docs\/durability-replication-failure-considerations.html\">Couchbase durability<\/a> options. This is still a distributed system &#8212; just like astronomy, rare things happen often. On any failure, the complete transaction is rolled back automatically and the application needs to retry the transaction. Failures can occur for various reasons: network failure, node failure, node overloaded, and write-write conflict.\u00a0 Just like direct Couchbase WRITEs are optimistic and failures can occur due to concurrent writes resulting in <a href=\"https:\/\/docs.couchbase.com\/java-sdk\/current\/howtos\/kv-operations.html#retrying-on-cas-failures\">CAS conflicts<\/a>, N1QL transactions can also fail due to write conflicts. We implement a form of <a href=\"https:\/\/en.wikipedia.org\/wiki\/Optimistic_concurrency_control\">optimistic concurrency<\/a> approach to transactions.<\/p>\n<h6><strong>ROLLBACK TRANSACTION or ROLLBACK WORK;<\/strong><\/h6>\n<p>On an application issued rollback, all of the modifications done within the transaction are rolled back.<\/p>\n<p>As you&#8217;ve seen from the examples above, N1QL also supports <strong>savepoints<\/strong> and rollbacks to the savepoints within the transaction.\u00a0 From the application perspective, these work the same as the RDBMS counterparts.<\/p>\n<p><strong>TRANSACTIONAL FEATURES<\/strong><\/p>\n<p>The transaction is more than just the statements &#8212; it&#8217;s all about the semantics and guarantees.\u00a0 Hence the <a href=\"https:\/\/en.wikipedia.org\/wiki\/ACID\">ACID<\/a> definition. We talked about atomicity earlier wrt to COMMIT.\u00a0 Let&#8217;s talk a bit more on this.<\/p>\n<p><strong>ATOMICITY\u00a0<\/strong>is required for both the whole transaction and each statement.\u00a0 The DML statements will atomically rollback on any failure, but the transaction itself is open and can be continued. An example of a failure is a document key conflict on insert.<\/p>\n<p><strong>CONSISTENCY<\/strong> ensures the constraints are applied consistently for each statement. The only constraint in Couchbase is the unique constraint on the document key.\u00a0 N1QL checks for the pre-existence of each of the key inserted and rolls back the statement on any conflict.\u00a0 Remember we use optimistic concurrency control.\u00a0 That means, even after the INSERT is successful,\u00a0 the commit stage can still run into a write-write conflict because some other session could have inserted between the insert and commit.\u00a0 \u00a0You&#8217;ll have to retry the transaction on such failures.<\/p>\n<p><strong>ISOLATION<\/strong><\/p>\n<p>We support the COMMITTED READ isolation level. All the data that&#8217;s read and evaluated is committed data in the index and data store. By default, we use the stringent <a href=\"https:\/\/docs.couchbase.com\/server\/current\/settings\/query-settings.html#section_nnj_sjk_k1b\">request_plus<\/a> consistency on the index reads.\u00a0 This means, for a given predicate, we use the latest data in the index to qualify the documents to qualify select\/update\/delete.\u00a0 We then go the extra step to fetch the documents from the KV store and re-apply the predicates to ensure the latest committed version of the document is qualified and updated.<\/p>\n<p>If performance wasn&#8217;t a consideration, everyone would have used serializable transactions ;-) You can change the scan consistency to <a href=\"https:\/\/docs.couchbase.com\/server\/current\/settings\/query-settings.html#section_nnj_sjk_k1b\">unbounded<\/a> for improved index scan performance.<\/p>\n<p><strong>DURABILITY<\/strong><\/p>\n<p>N1QL supports all of the <a href=\"https:\/\/docs.couchbase.com\/server\/current\/learn\/data\/durability.html\">durability options<\/a> and features with the Couchbase data store to ensure durability on our distributed database.<\/p>\n<p><strong>CONCURRENCY<\/strong><a href=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2020\/10\/Screen-Shot-2020-10-13-at-6.58.35-PM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-9445\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2020\/10\/Screen-Shot-2020-10-13-at-6.58.35-PM-300x74.png\" alt=\"\" width=\"876\" height=\"216\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/10\/Screen-Shot-2020-10-13-at-6.58.35-PM-300x74.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/10\/Screen-Shot-2020-10-13-at-6.58.35-PM-1024x251.png 1024w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/10\/Screen-Shot-2020-10-13-at-6.58.35-PM-768x188.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/10\/Screen-Shot-2020-10-13-at-6.58.35-PM-20x5.png 20w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/10\/Screen-Shot-2020-10-13-at-6.58.35-PM.png 1616w\" sizes=\"auto, (max-width: 876px) 100vw, 876px\" \/><\/a>Broadly speaking, database transactions use either pessimistic or optimistic <a href=\"https:\/\/en.wikipedia.org\/wiki\/Concurrency_control\">concurrency control<\/a>. Traditional single node databases follow the pessimistic concurrency control to avoid conflicts.\u00a0 This approach is also applied to some of the multi-node implementations like Oracle RAC, DB2 Sysplex. Multi-node implementations are possible but require expensive Infiniband, custom hardware, etc.<\/p>\n<p>Optimistic concurrency control version each base unit of tuple (rows in rdbms, documents in Couchbase), remember the version they read to modify and check if the version has changed during the write.\u00a0 If there&#8217;s indeed a conflict, the whole transaction has to be retried. The advantage of this approach is, in a well-designed application, there should be little conflicts: you won&#8217;t withdraw cash and transfer money between accounts at the same nanosecond.\u00a0 On the rare occasion you do, the retry is tolerated.<\/p>\n<h6><strong>Concurrency in the N1QL Query Service<\/strong><\/h6>\n<p>Couchbase N1QL uses optimistic concurrency control. Each transaction reads the documents it needs to update, updates them, and keeps the updated documents in its private <strong>per-transaction<\/strong> cache. When you issue a subsequent statement, the query service is aware of the updated documents within the transactions and uses that version instead of the older version reflected in the index\/data.\u00a0 This is how it provides READ-YOUR-OWN-WRITE support.\u00a0 This is modeled so all the DML statements, all operations (select, join, project, aggregate, nest, unnesst, etc) will all get this RYOW benefit providing a consistent and crucial feature of the transaction. Even while the application is doing transactions (doing both reads and writes), within the transaction we&#8217;re reading and caching the updates until the commit time. This is the READ phase of the transaction, And because of this approach, there&#8217;s no coordination between multiple transactions or multiple query nodes within a transaction until commit (WRITE phase). This ensures the performance and scalability of distributed transactions in Couchbase.\u00a0 And, before you ask,\u00a0 all these work concurrently with <a href=\"https:\/\/docs.couchbase.com\/java-sdk\/current\/howtos\/distributed-acid-transactions-from-the-sdk.html\">Couchbase distributed transactions<\/a> we <a href=\"https:\/\/connectonline.couchbase.com\/forum\/t\/distributed-acid-transactions-in-couchbase\/239\">released in 6.5<\/a>.<\/p>\n<blockquote><p><span style=\"color: #0000ff\">Coordination is the bane of scalable systems &#8212; <a style=\"color: #0000ff\" href=\"https:\/\/www.youtube.com\/watch?v=msRzhMVc4R8\">Peter Bailis<\/a><\/span><\/p><\/blockquote>\n<p><iframe loading=\"lazy\" title=\"&quot;When\u00a0&quot;Worst&quot;\u00a0is Best (in Distributed Systems)&quot; by Peter Bailis\" width=\"900\" height=\"506\" src=\"https:\/\/www.youtube.com\/embed\/ZGIAypUUwoQ?feature=oembed&#038;enablejsapi=1&#038;origin=https:\/\/www.couchbase.com\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" allowfullscreen><\/iframe><\/p>\n<p><strong>NEXT STEPS<\/strong><\/p>\n<p>We just announced that Couchbase 7.0 Beta will be in November 2020. Stay tuned for details.<\/p>\n<p>This is a short overview of what&#8217;s coming up with Couchbase Transactions.\u00a0 In the upcoming series of articles, we&#8217;ll dive further into implementation, usage, SDK support, Lambda Transactions, Spring support, etc, and more.<\/p>\n<p><strong>ACKNOWLEDGMENTS<\/strong><\/p>\n<p>I&#8217;m happy to announce N1QL transactions here.\u00a0 This is the result of intense work and collaboration in Couchbase query, SDK, and QE teams to design and implement.\u00a0 Thank you!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>SQL is the only 22nd-century language available for developers today. ABSTRACT In relational database systems, SQL is more than a declarative query language. It includes procedural language (T-SQL, PL\/SQL, etc) and defines transactions and its semantics.\u00a0 SQL as a query [&hellip;]<\/p>\n","protected":false},"author":55,"featured_media":9866,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[1815,2453,1812,2396],"tags":[1706,8191,1725,2221],"ppma_author":[8929],"class_list":["post-9439","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-best-practices-and-tutorials","category-global-secondary-index","category-n1ql-query","category-transactions","tag-concurrency","tag-distributed-transactions","tag-nosql-database","tag-transactions"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.8 (Yoast SEO v25.8) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>N1QL Transactions : Elastic, Scalable, and Distributed<\/title>\n<meta name=\"description\" content=\"N1QL transactions are multi-document, multi-bucket, multi-scope, multi collection, and multi-DML-statement. Read on to learn more!\" \/>\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\/transactions-n1ql-couchbase-distributed-nosql\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"N1QL Transactions : Elastic, Scalable, and Distributed\" \/>\n<meta property=\"og:description\" content=\"N1QL transactions are multi-document, multi-bucket, multi-scope, multi collection, and multi-DML-statement. Read on to learn more!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/transactions-n1ql-couchbase-distributed-nosql\/\" \/>\n<meta property=\"og:site_name\" content=\"The Couchbase Blog\" \/>\n<meta property=\"article:published_time\" content=\"2020-10-14T19:45:47+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-14T01:44:03+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/10\/N1QL-Transactions-An-Elastic-and-Scalable-Distributed-Transactions.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"627\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Keshav Murthy\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/10\/N1QL-Transactions-An-Elastic-and-Scalable-Distributed-Transactions.png\" \/>\n<meta name=\"twitter:creator\" content=\"@rkeshavmurthy\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Keshav Murthy\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/transactions-n1ql-couchbase-distributed-nosql\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/transactions-n1ql-couchbase-distributed-nosql\/\"},\"author\":{\"name\":\"Keshav Murthy\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/c261644262bf98e146372fe647682636\"},\"headline\":\"N1QL Transactions : Elastic, Scalable, and Distributed\",\"datePublished\":\"2020-10-14T19:45:47+00:00\",\"dateModified\":\"2025-06-14T01:44:03+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/transactions-n1ql-couchbase-distributed-nosql\/\"},\"wordCount\":1535,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/transactions-n1ql-couchbase-distributed-nosql\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/10\/Screen-Shot-2020-11-17-at-2.34.11-PM.png\",\"keywords\":[\"Concurrency\",\"distributed transactions\",\"NoSQL Database\",\"transactions\"],\"articleSection\":[\"Best Practices and Tutorials\",\"Global Secondary Index\",\"SQL++ \/ N1QL Query\",\"Transactions\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/transactions-n1ql-couchbase-distributed-nosql\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/transactions-n1ql-couchbase-distributed-nosql\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/transactions-n1ql-couchbase-distributed-nosql\/\",\"name\":\"N1QL Transactions : Elastic, Scalable, and Distributed\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/transactions-n1ql-couchbase-distributed-nosql\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/transactions-n1ql-couchbase-distributed-nosql\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/10\/Screen-Shot-2020-11-17-at-2.34.11-PM.png\",\"datePublished\":\"2020-10-14T19:45:47+00:00\",\"dateModified\":\"2025-06-14T01:44:03+00:00\",\"description\":\"N1QL transactions are multi-document, multi-bucket, multi-scope, multi collection, and multi-DML-statement. Read on to learn more!\",\"breadcrumb\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/transactions-n1ql-couchbase-distributed-nosql\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/transactions-n1ql-couchbase-distributed-nosql\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/transactions-n1ql-couchbase-distributed-nosql\/#primaryimage\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/10\/Screen-Shot-2020-11-17-at-2.34.11-PM.png\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/10\/Screen-Shot-2020-11-17-at-2.34.11-PM.png\",\"width\":2256,\"height\":874},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/transactions-n1ql-couchbase-distributed-nosql\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.couchbase.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"N1QL Transactions : Elastic, Scalable, and Distributed\"}]},{\"@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\/c261644262bf98e146372fe647682636\",\"name\":\"Keshav Murthy\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/4e51d72fc07c662aa791316deafffac4\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/af74df754db27152971d0aed2f323ead5a1f9fe5afd0209af91e12e784451224?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/af74df754db27152971d0aed2f323ead5a1f9fe5afd0209af91e12e784451224?s=96&d=mm&r=g\",\"caption\":\"Keshav Murthy\"},\"description\":\"Keshav Murthy is a Vice President at Couchbase R&amp;D. Previously, he was at MapR, IBM, Informix, Sybase, with more than 20 years of experience in database design &amp; development. He lead the SQL and NoSQL R&amp;D team at IBM Informix. He has received two President's Club awards at Couchbase, two Outstanding Technical Achievement Awards at IBM. Keshav has a bachelor's degree in Computer Science and Engineering from the University of Mysore, India, holds eleven US patents and has four US patents pending.\",\"sameAs\":[\"https:\/\/blog.planetnosql.com\/\",\"https:\/\/x.com\/rkeshavmurthy\"],\"url\":\"https:\/\/www.couchbase.com\/blog\/author\/keshav-murthy\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"N1QL Transactions : Elastic, Scalable, and Distributed","description":"N1QL transactions are multi-document, multi-bucket, multi-scope, multi collection, and multi-DML-statement. Read on to learn more!","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\/transactions-n1ql-couchbase-distributed-nosql\/","og_locale":"en_US","og_type":"article","og_title":"N1QL Transactions : Elastic, Scalable, and Distributed","og_description":"N1QL transactions are multi-document, multi-bucket, multi-scope, multi collection, and multi-DML-statement. Read on to learn more!","og_url":"https:\/\/www.couchbase.com\/blog\/transactions-n1ql-couchbase-distributed-nosql\/","og_site_name":"The Couchbase Blog","article_published_time":"2020-10-14T19:45:47+00:00","article_modified_time":"2025-06-14T01:44:03+00:00","og_image":[{"width":1200,"height":627,"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/10\/N1QL-Transactions-An-Elastic-and-Scalable-Distributed-Transactions.png","type":"image\/png"}],"author":"Keshav Murthy","twitter_card":"summary_large_image","twitter_image":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/10\/N1QL-Transactions-An-Elastic-and-Scalable-Distributed-Transactions.png","twitter_creator":"@rkeshavmurthy","twitter_misc":{"Written by":"Keshav Murthy","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.couchbase.com\/blog\/transactions-n1ql-couchbase-distributed-nosql\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/transactions-n1ql-couchbase-distributed-nosql\/"},"author":{"name":"Keshav Murthy","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/c261644262bf98e146372fe647682636"},"headline":"N1QL Transactions : Elastic, Scalable, and Distributed","datePublished":"2020-10-14T19:45:47+00:00","dateModified":"2025-06-14T01:44:03+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/transactions-n1ql-couchbase-distributed-nosql\/"},"wordCount":1535,"commentCount":0,"publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/transactions-n1ql-couchbase-distributed-nosql\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/10\/Screen-Shot-2020-11-17-at-2.34.11-PM.png","keywords":["Concurrency","distributed transactions","NoSQL Database","transactions"],"articleSection":["Best Practices and Tutorials","Global Secondary Index","SQL++ \/ N1QL Query","Transactions"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/blog\/transactions-n1ql-couchbase-distributed-nosql\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/transactions-n1ql-couchbase-distributed-nosql\/","url":"https:\/\/www.couchbase.com\/blog\/transactions-n1ql-couchbase-distributed-nosql\/","name":"N1QL Transactions : Elastic, Scalable, and Distributed","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/transactions-n1ql-couchbase-distributed-nosql\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/transactions-n1ql-couchbase-distributed-nosql\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/10\/Screen-Shot-2020-11-17-at-2.34.11-PM.png","datePublished":"2020-10-14T19:45:47+00:00","dateModified":"2025-06-14T01:44:03+00:00","description":"N1QL transactions are multi-document, multi-bucket, multi-scope, multi collection, and multi-DML-statement. Read on to learn more!","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/transactions-n1ql-couchbase-distributed-nosql\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/transactions-n1ql-couchbase-distributed-nosql\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/transactions-n1ql-couchbase-distributed-nosql\/#primaryimage","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/10\/Screen-Shot-2020-11-17-at-2.34.11-PM.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/10\/Screen-Shot-2020-11-17-at-2.34.11-PM.png","width":2256,"height":874},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/blog\/transactions-n1ql-couchbase-distributed-nosql\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/blog\/"},{"@type":"ListItem","position":2,"name":"N1QL Transactions : Elastic, Scalable, and Distributed"}]},{"@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\/c261644262bf98e146372fe647682636","name":"Keshav Murthy","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/4e51d72fc07c662aa791316deafffac4","url":"https:\/\/secure.gravatar.com\/avatar\/af74df754db27152971d0aed2f323ead5a1f9fe5afd0209af91e12e784451224?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/af74df754db27152971d0aed2f323ead5a1f9fe5afd0209af91e12e784451224?s=96&d=mm&r=g","caption":"Keshav Murthy"},"description":"Keshav Murthy is a Vice President at Couchbase R&amp;D. Previously, he was at MapR, IBM, Informix, Sybase, with more than 20 years of experience in database design &amp; development. He lead the SQL and NoSQL R&amp;D team at IBM Informix. He has received two President's Club awards at Couchbase, two Outstanding Technical Achievement Awards at IBM. Keshav has a bachelor's degree in Computer Science and Engineering from the University of Mysore, India, holds eleven US patents and has four US patents pending.","sameAs":["https:\/\/blog.planetnosql.com\/","https:\/\/x.com\/rkeshavmurthy"],"url":"https:\/\/www.couchbase.com\/blog\/author\/keshav-murthy\/"}]}},"authors":[{"term_id":8929,"user_id":55,"is_guest":0,"slug":"keshav-murthy","display_name":"Keshav Murthy","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/af74df754db27152971d0aed2f323ead5a1f9fe5afd0209af91e12e784451224?s=96&d=mm&r=g","author_category":"","last_name":"Murthy","first_name":"Keshav","job_title":"","user_url":"https:\/\/blog.planetnosql.com\/","description":"Keshav Murthy is a Vice President at Couchbase R&amp;D. Previously, he was at MapR, IBM, Informix, Sybase, with more than 20 years of experience in database design &amp; development. He lead the SQL and NoSQL R&amp;D team at IBM Informix. He has received two President's Club awards at Couchbase, two Outstanding Technical Achievement Awards at IBM. Keshav has a bachelor's degree in Computer Science and Engineering from the University of Mysore, India,  holds ten US patents and has three US patents pending."}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/9439","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\/55"}],"replies":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/comments?post=9439"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/9439\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media\/9866"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media?parent=9439"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/categories?post=9439"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/tags?post=9439"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=9439"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}