{"id":3473,"date":"2024-04-05T09:33:32","date_gmt":"2024-04-05T16:33:32","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/improved-debuggability-for-sql-user-defined-functions\/"},"modified":"2024-04-05T09:33:32","modified_gmt":"2024-04-05T16:33:32","slug":"improved-debuggability-for-sql-user-defined-functions","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/pt\/improved-debuggability-for-sql-user-defined-functions\/","title":{"rendered":"Improved Debuggability for SQL++ User-Defined Functions"},"content":{"rendered":"\n<p><span><a href=\"https:\/\/docs.couchbase.com\/server\/current\/n1ql\/n1ql-language-reference\/userfun.html\">User-defined functions (UDFs)<\/a> are a very useful feature supported in SQL++.\u00a0<\/span><span>Couchbase 7.6 introduces improvements that allow for more debuggability and visibility into UDF execution.<\/span><\/p>\n\n\n\n<p><span>This blog will explore two new features in Couchbase 7.6 in the world of UDFs.<\/span><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><span>Profiling for SQL++ statements executed in JavaScript UDFs<\/span><\/li>\n\n\n<li><span>EXPLAIN FUNCTION to access query plans of SQL++ statements within UDFs<\/span><\/li>\n\n<\/ol>\n\n\n\n<p><span>The examples in this post require the <a href=\"https:\/\/docs.couchbase.com\/server\/current\/manage\/manage-settings\/install-sample-buckets.html\">travel-sample dataset<\/a> to be installed.<\/span><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Profiling SQL++ Executed in JavaScript UDFs<\/h2>\n\n\n\n<p><span>Query profiling is a debuggability feature that SQL++ offers.<\/span><\/p>\n\n\n\n<p><span>When profiling is enabled for a statement\u2019s execution, the result of the request includes a detailed execution tree with timing and metrics of each step of the statement\u2019s execution. In addition to the profiling information being returned in the results of the statement, it can also be accessed for the request in the <em>system:active_requests<\/em> and <em>system:completed_requests<\/em> system keyspaces.<\/span><\/p>\n\n\n\n<p><span>Here is a post that <a href=\"https:\/\/www.couchbase.com\/blog\/optimize-n1ql-performance-using-request-profiling\/\">delves deeper into request profiling<\/a>.<\/span><\/p>\n\n\n\n<p><span>In Couchbase 7.0, profiling was included for subqueries, including profiling subqueries from <em>Inline UDFs<\/em>.<\/span><\/p>\n\n\n\n<p><span>However, with new features in Couchbase 7.6, profiling was extended to SQL++ statements within <em>JavaScript UDFs<\/em>.<\/span><\/p>\n\n\n\n<p><span>In earlier versions, to profile statements within a JavaScript UDF, the user would be required to open up the function\u2019s definition, individually run each statement within the UDF and collect their profiles. This additional step will no longer be needed in 7.6.0!<\/span><\/p>\n\n\n\n<p><span>Now, when profiling is enabled, if the statement contains JavaScript UDF execution, profiles for all SQL++ statements executed in the UDF will also be collected. And this UDF related profiling information will be available in the request output, <em>system:active_requests<\/em> and <em>system:completed_requests<\/em> system keyspaces as well.<\/span><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span>Example 1:<\/span><\/h3>\n\n\n\n<p><span>Create a JavaScript UDF <em>js1<\/em> in a global library <em>lib1<\/em>\u00a0via the REST endpoint or via the UI.<\/span><\/p>\n\n\n<p>[crayon nums=&#8221;false&#8221; lang=&#8221;js&#8221; decode=&#8221;true&#8221;]function js1() {<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0var query = SELECT * FROM default:`travel-sample`.inventory.airline LIMIT 1;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0var res = [];<br \/>\n\u00a0\u00a0\u00a0\u00a0for (const row of query) {<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0res.push(row);<br \/>\n\u00a0\u00a0\u00a0}<br \/>\n\u00a0\u00a0\u00a0\u00a0query.close()<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0return res;<br \/>\n}[\/crayon]<\/p>\n\n\n\n<p><span>Create the corresponding SQL++ function:<\/span><\/p>\n\n\n<p>[crayon nums=&#8221;false&#8221; lang=&#8221;default&#8221; decode=&#8221;true&#8221;]CREATE FUNCTION js1() LANGUAGE JAVASCRIPT AS &#8220;js1&#8221; AT &#8220;lib1&#8221;;[\/crayon]<\/p>\n\n\n\n<p><span> Execute the UDF with profiling enabled:<\/span><\/p>\n\n\n<p>[crayon nums=&#8221;false&#8221; lang=&#8221;default&#8221; decode=&#8221;true&#8221;]EXECUTE FUNCTION js1();<br \/>\n[\/crayon]<\/p>\n\n\n\n<p><span>In the <\/span><b>profile<\/b><span> section of the returned response, the <\/span><b>executionTimings<\/b><span> subsection contains a field <\/span><b>~udfStatements<\/b><span>.<\/span><\/p>\n\n\n\n<p><b>~udfStatements<\/b><span>\u00a0is an array of profiling information that contains an entry for every SQL++ statement within the JavaScript UDF.<\/span><\/p>\n\n\n\n<p><span>Every entry within the <\/span><b>~udfStatements<\/b><span> section contains:<\/span><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><b>executionTimings <\/b>&#8211; <span>The execution tree for the statement. It has metrics and timings information of every step of the statement\u2019s execution.<\/span><\/li>\n\n\n<li><b>statement<\/b> &#8211; <span>The statement string.<\/span><\/li>\n\n\n<li><b>function<\/b> &#8211; <span>The name of the function where the statement was executed. This is helpful to identify the UDF that executed the statement when there are nested UDF executions.<\/span><\/li>\n\n<\/ul>\n\n\n<p>[crayon lang=&#8221;js&#8221; decode=&#8221;true&#8221;]{<br \/>\n  &#8220;requestID&#8221;: &#8220;2c5576b5-f01d-445f-a35b-2213c606f394&#8221;,<br \/>\n  &#8220;signature&#8221;: null,<br \/>\n  &#8220;results&#8221;: [<br \/>\n    [<br \/>\n      {<br \/>\n        &#8220;airline&#8221;: {<br \/>\n          &#8220;callsign&#8221;: &#8220;MILE-AIR&#8221;,<br \/>\n          &#8220;country&#8221;: &#8220;United States&#8221;,<br \/>\n          &#8220;iata&#8221;: &#8220;Q5&#8221;,<br \/>\n          &#8220;icao&#8221;: &#8220;MLA&#8221;,<br \/>\n          &#8220;id&#8221;: 10,<br \/>\n          &#8220;name&#8221;: &#8220;40-Mile Air&#8221;,<br \/>\n          &#8220;type&#8221;: &#8220;airline&#8221;<br \/>\n        }<br \/>\n      }<br \/>\n    ]<br \/>\n  ],<br \/>\n  &#8220;status&#8221;: &#8220;success&#8221;,<br \/>\n  &#8220;metrics&#8221;: {<br \/>\n    &#8220;elapsedTime&#8221;: &#8220;20.757583ms&#8221;,<br \/>\n    &#8220;executionTime&#8221;: &#8220;20.636792ms&#8221;,<br \/>\n    &#8220;resultCount&#8221;: 1,<br \/>\n    &#8220;resultSize&#8221;: 310,<br \/>\n    &#8220;serviceLoad&#8221;: 2<br \/>\n  },<br \/>\n  &#8220;profile&#8221;: {<br \/>\n    &#8220;phaseTimes&#8221;: {<br \/>\n      &#8220;authorize&#8221;: &#8220;12.835\u00b5s&#8221;,<br \/>\n      &#8220;fetch&#8221;: &#8220;374.667\u00b5s&#8221;,<br \/>\n      &#8220;instantiate&#8221;: &#8220;27.75\u00b5s&#8221;,<br \/>\n      &#8220;parse&#8221;: &#8220;251.708\u00b5s&#8221;,<br \/>\n      &#8220;plan&#8221;: &#8220;9.125\u00b5s&#8221;,<br \/>\n      &#8220;primaryScan&#8221;: &#8220;813.249\u00b5s&#8221;,<br \/>\n      &#8220;primaryScan.GSI&#8221;: &#8220;813.249\u00b5s&#8221;,<br \/>\n      &#8220;project&#8221;: &#8220;5.541\u00b5s&#8221;,<br \/>\n      &#8220;run&#8221;: &#8220;27.925833ms&#8221;,<br \/>\n      &#8220;stream&#8221;: &#8220;26.375\u00b5s&#8221;<br \/>\n    },<br \/>\n    &#8220;phaseCounts&#8221;: {<br \/>\n      &#8220;fetch&#8221;: 1,<br \/>\n      &#8220;primaryScan&#8221;: 1,<br \/>\n      &#8220;primaryScan.GSI&#8221;: 1<br \/>\n    },<br \/>\n    &#8220;phaseOperators&#8221;: {<br \/>\n      &#8220;authorize&#8221;: 2,<br \/>\n      &#8220;fetch&#8221;: 1,<br \/>\n      &#8220;primaryScan&#8221;: 1,<br \/>\n      &#8220;primaryScan.GSI&#8221;: 1,<br \/>\n      &#8220;project&#8221;: 1,<br \/>\n      &#8220;stream&#8221;: 1<br \/>\n    },<br \/>\n    &#8220;cpuTime&#8221;: &#8220;468.626\u00b5s&#8221;,<br \/>\n    &#8220;requestTime&#8221;: &#8220;2023-12-04T20:30:00.369+05:30&#8221;,<br \/>\n    &#8220;servicingHost&#8221;: &#8220;127.0.0.1:8091&#8221;,<br \/>\n    &#8220;executionTimings&#8221;: {<br \/>\n      &#8220;#operator&#8221;: &#8220;Authorize&#8221;,<br \/>\n      &#8220;#planPreparedTime&#8221;: &#8220;2023-12-04T20:30:00.369+05:30&#8221;,<br \/>\n      &#8220;#stats&#8221;: {<br \/>\n        &#8220;#phaseSwitches&#8221;: 4,<br \/>\n        &#8220;execTime&#8221;: &#8220;1.918\u00b5s&#8221;,<br \/>\n        &#8220;servTime&#8221;: &#8220;1.125\u00b5s&#8221;<br \/>\n      },<br \/>\n      &#8220;privileges&#8221;: {<br \/>\n        &#8220;List&#8221;: []<br \/>\n      },<br \/>\n      &#8220;~child&#8221;: {<br \/>\n        &#8220;#operator&#8221;: &#8220;Sequence&#8221;,<br \/>\n        &#8220;#stats&#8221;: {<br \/>\n          &#8220;#phaseSwitches&#8221;: 2,<br \/>\n          &#8220;execTime&#8221;: &#8220;2.208\u00b5s&#8221;<br \/>\n        },<br \/>\n        &#8220;~children&#8221;: [<br \/>\n          {<br \/>\n            &#8220;#operator&#8221;: &#8220;ExecuteFunction&#8221;,<br \/>\n            &#8220;#stats&#8221;: {<br \/>\n              &#8220;#itemsOut&#8221;: 1,<br \/>\n              &#8220;#phaseSwitches&#8221;: 4,<br \/>\n              &#8220;execTime&#8221;: &#8220;22.375\u00b5s&#8221;,<br \/>\n              &#8220;kernTime&#8221;: &#8220;20.271708ms&#8221;<br \/>\n            },<br \/>\n            &#8220;identity&#8221;: {<br \/>\n              &#8220;name&#8221;: &#8220;js1&#8221;,<br \/>\n              &#8220;namespace&#8221;: &#8220;default&#8221;,<br \/>\n              &#8220;type&#8221;: &#8220;global&#8221;<br \/>\n            }<br \/>\n          },<br \/>\n          {<br \/>\n            &#8220;#operator&#8221;: &#8220;Stream&#8221;,<br \/>\n            &#8220;#stats&#8221;: {<br \/>\n              &#8220;#itemsIn&#8221;: 1,<br \/>\n              &#8220;#itemsOut&#8221;: 1,<br \/>\n              &#8220;#phaseSwitches&#8221;: 2,<br \/>\n              &#8220;execTime&#8221;: &#8220;26.375\u00b5s&#8221;<br \/>\n            },<br \/>\n            &#8220;serializable&#8221;: true<br \/>\n          }<br \/>\n        ]<br \/>\n      },<br \/>\n      &#8220;~udfStatements&#8221;: [<br \/>\n        {<br \/>\n          &#8220;executionTimings&#8221;: {<br \/>\n            &#8220;#operator&#8221;: &#8220;Authorize&#8221;,<br \/>\n            &#8220;#stats&#8221;: {<br \/>\n              &#8220;#phaseSwitches&#8221;: 4,<br \/>\n              &#8220;execTime&#8221;: &#8220;2.626\u00b5s&#8221;,<br \/>\n              &#8220;servTime&#8221;: &#8220;7.166\u00b5s&#8221;<br \/>\n            },<br \/>\n            &#8220;privileges&#8221;: {<br \/>\n              &#8220;List&#8221;: [<br \/>\n                {<br \/>\n                  &#8220;Priv&#8221;: 7,<br \/>\n                  &#8220;Props&#8221;: 0,<br \/>\n                  &#8220;Target&#8221;: &#8220;default:travel-sample.inventory.airline&#8221;<br \/>\n                }<br \/>\n              ]<br \/>\n            },<br \/>\n            &#8220;~child&#8221;: {<br \/>\n              &#8220;#operator&#8221;: &#8220;Sequence&#8221;,<br \/>\n              &#8220;#stats&#8221;: {<br \/>\n                &#8220;#phaseSwitches&#8221;: 2,<br \/>\n                &#8220;execTime&#8221;: &#8220;4.375\u00b5s&#8221;<br \/>\n              },<br \/>\n              &#8220;~children&#8221;: [<br \/>\n                {<br \/>\n                  &#8220;#operator&#8221;: &#8220;PrimaryScan3&#8221;,<br \/>\n                  &#8220;#stats&#8221;: {<br \/>\n                    &#8220;#itemsIn&#8221;: 1,<br \/>\n                    &#8220;#itemsOut&#8221;: 1,<br \/>\n                    &#8220;#phaseSwitches&#8221;: 7,<br \/>\n                    &#8220;execTime&#8221;: &#8220;22.082\u00b5s&#8221;,<br \/>\n                    &#8220;kernTime&#8221;: &#8220;1.584\u00b5s&#8221;,<br \/>\n                    &#8220;servTime&#8221;: &#8220;791.167\u00b5s&#8221;<br \/>\n                  },<br \/>\n                  &#8220;bucket&#8221;: &#8220;travel-sample&#8221;,<br \/>\n                  &#8220;index&#8221;: &#8220;def_inventory_airline_primary&#8221;,<br \/>\n                  &#8220;index_projection&#8221;: {<br \/>\n                    &#8220;primary_key&#8221;: true<br \/>\n                  },<br \/>\n                  &#8220;keyspace&#8221;: &#8220;airline&#8221;,<br \/>\n                  &#8220;limit&#8221;: &#8220;1&#8221;,<br \/>\n                  &#8220;namespace&#8221;: &#8220;default&#8221;,<br \/>\n                  &#8220;optimizer_estimates&#8221;: {<br \/>\n                    &#8220;cardinality&#8221;: 187,<br \/>\n                    &#8220;cost&#8221;: 45.28617059639748,<br \/>\n                    &#8220;fr_cost&#8221;: 12.1780009122802,<br \/>\n                    &#8220;size&#8221;: 12<br \/>\n                  },<br \/>\n                  &#8220;scope&#8221;: &#8220;inventory&#8221;,<br \/>\n                  &#8220;using&#8221;: &#8220;gsi&#8221;<br \/>\n                },<br \/>\n                {<br \/>\n                  &#8220;#operator&#8221;: &#8220;Fetch&#8221;,<br \/>\n                  &#8220;#stats&#8221;: {<br \/>\n                    &#8220;#itemsIn&#8221;: 1,<br \/>\n                    &#8220;#itemsOut&#8221;: 1,<br \/>\n                    &#8220;#phaseSwitches&#8221;: 10,<br \/>\n                    &#8220;execTime&#8221;: &#8220;18.376\u00b5s&#8221;,<br \/>\n                    &#8220;kernTime&#8221;: &#8220;797.542\u00b5s&#8221;,<br \/>\n                    &#8220;servTime&#8221;: &#8220;356.291\u00b5s&#8221;<br \/>\n                  },<br \/>\n                  &#8220;bucket&#8221;: &#8220;travel-sample&#8221;,<br \/>\n                  &#8220;keyspace&#8221;: &#8220;airline&#8221;,<br \/>\n                  &#8220;namespace&#8221;: &#8220;default&#8221;,<br \/>\n                  &#8220;optimizer_estimates&#8221;: {<br \/>\n                    &#8220;cardinality&#8221;: 187,<br \/>\n                    &#8220;cost&#8221;: 192.01699202888378,<br \/>\n                    &#8220;fr_cost&#8221;: 24.89848658838975,<br \/>\n                    &#8220;size&#8221;: 204<br \/>\n                  },<br \/>\n                  &#8220;scope&#8221;: &#8220;inventory&#8221;<br \/>\n                },<br \/>\n                {<br \/>\n                  &#8220;#operator&#8221;: &#8220;InitialProject&#8221;,<br \/>\n                  &#8220;#stats&#8221;: {<br \/>\n                    &#8220;#itemsIn&#8221;: 1,<br \/>\n                    &#8220;#itemsOut&#8221;: 1,<br \/>\n                    &#8220;#phaseSwitches&#8221;: 7,<br \/>\n                    &#8220;execTime&#8221;: &#8220;5.541\u00b5s&#8221;,<br \/>\n                    &#8220;kernTime&#8221;: &#8220;1.1795ms&#8221;<br \/>\n                  },<br \/>\n                  &#8220;discard_original&#8221;: true,<br \/>\n                  &#8220;optimizer_estimates&#8221;: {<br \/>\n                    &#8220;cardinality&#8221;: 187,<br \/>\n                    &#8220;cost&#8221;: 194.6878862611588,<br \/>\n                    &#8220;fr_cost&#8221;: 24.912769445246838,<br \/>\n                    &#8220;size&#8221;: 204<br \/>\n                  },<br \/>\n                  &#8220;preserve_order&#8221;: true,<br \/>\n                  &#8220;result_terms&#8221;: [<br \/>\n                    {<br \/>\n                      &#8220;expr&#8221;: &#8220;self&#8221;,<br \/>\n                      &#8220;star&#8221;: true<br \/>\n                    }<br \/>\n                  ]<br \/>\n                },<br \/>\n                {<br \/>\n                  &#8220;#operator&#8221;: &#8220;Limit&#8221;,<br \/>\n                  &#8220;#stats&#8221;: {<br \/>\n                    &#8220;#itemsIn&#8221;: 1,<br \/>\n                    &#8220;#itemsOut&#8221;: 1,<br \/>\n                    &#8220;#phaseSwitches&#8221;: 4,<br \/>\n                    &#8220;execTime&#8221;: &#8220;6.25\u00b5s&#8221;,<br \/>\n                    &#8220;kernTime&#8221;: &#8220;333ns&#8221;<br \/>\n                  },<br \/>\n                  &#8220;expr&#8221;: &#8220;1&#8221;,<br \/>\n                  &#8220;optimizer_estimates&#8221;: {<br \/>\n                    &#8220;cardinality&#8221;: 1,<br \/>\n                    &#8220;cost&#8221;: 24.927052302103924,<br \/>\n                    &#8220;fr_cost&#8221;: 24.927052302103924,<br \/>\n                    &#8220;size&#8221;: 204<br \/>\n                  }<br \/>\n                },<br \/>\n                {<br \/>\n                  &#8220;#operator&#8221;: &#8220;Receive&#8221;,<br \/>\n                  &#8220;#stats&#8221;: {<br \/>\n                    &#8220;#phaseSwitches&#8221;: 3,<br \/>\n                    &#8220;execTime&#8221;: &#8220;10.324833ms&#8221;,<br \/>\n                    &#8220;kernTime&#8221;: &#8220;792ns&#8221;,<br \/>\n                    &#8220;state&#8221;: &#8220;running&#8221;<br \/>\n                  }<br \/>\n                }<br \/>\n              ]<br \/>\n            }<br \/>\n          },<br \/>\n          &#8220;statement&#8221;: &#8220;SELECT * FROM default:`travel-sample`.inventory.airline LIMIT 1;&#8221;,<br \/>\n          &#8220;function&#8221;: &#8220;default:js1&#8221;<br \/>\n        }<br \/>\n      ],<br \/>\n      &#8220;~versions&#8221;: [<br \/>\n        &#8220;7.6.0-N1QL&#8221;,<br \/>\n        &#8220;7.6.0-1847-enterprise&#8221;<br \/>\n      ]<br \/>\n    }<br \/>\n  }<br \/>\n}[\/crayon]<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Query Plans with EXPLAIN FUNCTION<\/h2>\n\n\n\n<p><span>SQL++ offers another wonderful capability to access the plan of a statement with the EXPLAIN statement. But the EXPLAIN statement does not extend to plans of statements within UDFs\u2014neither Inline or JavaScript UDFs.<\/span><\/p>\n\n\n\n<p><span>In earlier versions, to analyze the query plans for SQL++ within a UDF it would require the user to open the function\u2019s definition, and individually run an EXPLAIN on all the statements within the UDF.<\/span><\/p>\n\n\n\n<p><span>These extra steps are minimized in Couchbase 7.6 with the introduction of a new statement\u2014<em>EXPLAIN FUNCTION<\/em>. This statement does exactly what EXPLAIN does, but for SQL++ statements within a UDF.<\/span><\/p>\n\n\n\n<p><span>Let\u2019s explore how to use the EXPLAIN FUNCTION statement!<\/span><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Syntax<\/h3>\n\n\n<p>[crayon lang=&#8221;default&#8221; decode=&#8221;true&#8221;]explain_function ::= &#8216;EXPLAIN&#8217; &#8216;FUNCTION&#8217; function[\/crayon]<\/p>\n\n\n\n<p><span>Here, <em>function<\/em>\u00a0refers to the name of the function.<\/span><\/p>\n\n\n\n<p><span>For more detailed information on syntax, please check out the documentation.<\/span><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Prerequisites<\/h3>\n\n\n\n<p><span>To run EXPLAIN FUNCTION on a UDF, the user must have sufficient <a href=\"https:\/\/docs.couchbase.com\/server\/current\/n1ql\/n1ql-language-reference\/userfun.html#rbac-privileges\">RBAC permissions<\/a> to <\/span><i><span>execute<\/span><\/i><span> the function.<\/span><\/p>\n\n\n\n<p><span>The user must also have the necessary RBAC permissions to execute the SQL++ statements within the UDF function body.<\/span><\/p>\n\n\n\n<p><span>Here are the <a href=\"https:\/\/docs.couchbase.com\/server\/current\/learn\/security\/roles.html\">roles supported in Couchbase<\/a>.<\/span><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Inline UDF<\/h3>\n\n\n\n<p><span>EXPLAIN FUNCTION on an inline UDF will return the query plans of all the subqueries within its definition.<\/span><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span>Example 2 &#8211; EXPLAIN FUNCTION on an inline function<\/span><\/h3>\n\n\n\n<p><span>Create an inline UDF and run EXPLAIN FUNCTION on it:<\/span><\/p>\n\n\n<p>[crayon lang=&#8221;default&#8221; decode=&#8221;true&#8221;]CREATE FUNCTION inline1() { (\u00a0\u00a0<br \/>\n\u00a0 SELECT * FROM default:`travel-sample`.inventory.airport WHERE city = &#8220;Zachar Bay&#8221;<br \/>\n) };[\/crayon]<\/p>\n\n\n<p>[crayon lang=&#8221;default&#8221; decode=&#8221;true&#8221;]EXPLAIN FUNCTION inline1();[\/crayon]<\/p>\n\n\n\n<p><span>The results of the above statement will contain:<\/span><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><b>function<\/b><span>\u00a0&#8211; The name of the function EXPLAIN FUNCTION was run on.<\/span><\/li>\n\n\n<li><b>plans<\/b><span>\u00a0&#8211; An array of plan information that contains an entry for every subquery within the Inline UDF.<\/span><\/li>\n\n<\/ul>\n\n\n<p>[crayon lang=&#8221;js&#8221; decode=&#8221;true&#8221;]{<br \/>\n        &#8220;function&#8221;: &#8220;default:inline1&#8221;,<br \/>\n        &#8220;plans&#8221;: [<br \/>\n            {<br \/>\n                &#8220;cardinality&#8221;: 1.1176470588235294,<br \/>\n                &#8220;cost&#8221;: 25.117642854609013,<br \/>\n                &#8220;plan&#8221;: {<br \/>\n                    &#8220;#operator&#8221;: &#8220;Sequence&#8221;,<br \/>\n                    &#8220;~children&#8221;: [<br \/>\n                        {<br \/>\n                            &#8220;#operator&#8221;: &#8220;IndexScan3&#8221;,<br \/>\n                            &#8220;bucket&#8221;: &#8220;travel-sample&#8221;,<br \/>\n                            &#8220;index&#8221;: &#8220;def_inventory_airport_city&#8221;,<br \/>\n                            &#8220;index_id&#8221;: &#8220;2605c88c115dd3a2&#8221;,<br \/>\n                            &#8220;index_projection&#8221;: {<br \/>\n                                &#8220;primary_key&#8221;: true<br \/>\n                            },<br \/>\n                            &#8220;keyspace&#8221;: &#8220;airport&#8221;,<br \/>\n                            &#8220;namespace&#8221;: &#8220;default&#8221;,<br \/>\n                            &#8220;optimizer_estimates&#8221;: {<br \/>\n                                &#8220;cardinality&#8221;: 1.1176470588235294,<br \/>\n                                &#8220;cost&#8221;: 12.200561852726496,<br \/>\n                                &#8220;fr_cost&#8221;: 12.179450078755286,<br \/>\n                                &#8220;size&#8221;: 12<br \/>\n                            },<br \/>\n                            &#8220;scope&#8221;: &#8220;inventory&#8221;,<br \/>\n                            &#8220;spans&#8221;: [<br \/>\n                                {<br \/>\n                                    &#8220;exact&#8221;: true,<br \/>\n                                    &#8220;range&#8221;: [<br \/>\n                                        {<br \/>\n                                            &#8220;high&#8221;: &#8220;\\&#8221;Zachar Bay\\&#8221;&#8221;,<br \/>\n                                            &#8220;inclusion&#8221;: 3,<br \/>\n                                            &#8220;index_key&#8221;: &#8220;`city`&#8221;,<br \/>\n                                            &#8220;low&#8221;: &#8220;\\&#8221;Zachar Bay\\&#8221;&#8221;<br \/>\n                                        }<br \/>\n                                    ]<br \/>\n                                }<br \/>\n                            ],<br \/>\n                            &#8220;using&#8221;: &#8220;gsi&#8221;<br \/>\n                        },<br \/>\n                        {<br \/>\n                            &#8220;#operator&#8221;: &#8220;Fetch&#8221;,<br \/>\n                            &#8220;bucket&#8221;: &#8220;travel-sample&#8221;,<br \/>\n                            &#8220;keyspace&#8221;: &#8220;airport&#8221;,<br \/>\n                            &#8220;namespace&#8221;: &#8220;default&#8221;,<br \/>\n                            &#8220;optimizer_estimates&#8221;: {<br \/>\n                                &#8220;cardinality&#8221;: 1.1176470588235294,<br \/>\n                                &#8220;cost&#8221;: 25.082370508382763,<br \/>\n                                &#8220;fr_cost&#8221;: 24.96843677065826,<br \/>\n                                &#8220;size&#8221;: 249<br \/>\n                            },<br \/>\n                            &#8220;scope&#8221;: &#8220;inventory&#8221;<br \/>\n                        },<br \/>\n                        {<br \/>\n                            &#8220;#operator&#8221;: &#8220;Parallel&#8221;,<br \/>\n                            &#8220;~child&#8221;: {<br \/>\n                                &#8220;#operator&#8221;: &#8220;Sequence&#8221;,<br \/>\n                                &#8220;~children&#8221;: [<br \/>\n                                    {<br \/>\n                                        &#8220;#operator&#8221;: &#8220;Filter&#8221;,<br \/>\n                                        &#8220;condition&#8221;: &#8220;((`airport`.`city`) = \\&#8221;Zachar Bay\\&#8221;)&#8221;,<br \/>\n                                        &#8220;optimizer_estimates&#8221;: {<br \/>\n                                            &#8220;cardinality&#8221;: 1.1176470588235294,<br \/>\n                                            &#8220;cost&#8221;: 25.100006681495888,<br \/>\n                                            &#8220;fr_cost&#8221;: 24.98421650449632,<br \/>\n                                            &#8220;size&#8221;: 249<br \/>\n                                        }<br \/>\n                                    },<br \/>\n                                    {<br \/>\n                                        &#8220;#operator&#8221;: &#8220;InitialProject&#8221;,<br \/>\n                                        &#8220;discard_original&#8221;: true,<br \/>\n                                        &#8220;optimizer_estimates&#8221;: {<br \/>\n                                            &#8220;cardinality&#8221;: 1.1176470588235294,<br \/>\n                                            &#8220;cost&#8221;: 25.117642854609013,<br \/>\n                                            &#8220;fr_cost&#8221;: 24.99999623833438,<br \/>\n                                            &#8220;size&#8221;: 249<br \/>\n                                        },<br \/>\n                                        &#8220;result_terms&#8221;: [<br \/>\n                                            {<br \/>\n                                                &#8220;expr&#8221;: &#8220;self&#8221;,<br \/>\n                                                &#8220;star&#8221;: true<br \/>\n                                            }<br \/>\n                                        ]<br \/>\n                                    }<br \/>\n                                ]<br \/>\n                            }<br \/>\n                        }<br \/>\n                    ]<br \/>\n                },<br \/>\n                &#8220;statement&#8221;: &#8220;select self.* from `default`:`travel-sample`.`inventory`.`airport` where ((`airport`.`city`) = \\&#8221;Zachar Bay\\&#8221;)&#8221;<br \/>\n            }<br \/>\n        ]<br \/>\n    }[\/crayon]<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">JavaScript UDF<\/h3>\n\n\n\n<p><span>SQL++ statements within JavaScript UDFs can be of two types and EXPLAIN FUNCTION works differently based on the way the SQL++ statement is called.<\/span><\/p>\n\n\n\n<p><span>Here is the documentation reference to <a href=\"https:\/\/docs.couchbase.com\/server\/current\/javascript-udfs\/calling-n1ql-from-javascript.html\">calling SQL++ in JavaScript functions<\/a>.<\/span><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Embedded SQL++<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span>Embedded SQL++ is \u201cembedded\u201d in the function body and its detection is handled by the JavaScript transpiler.<\/span><\/li>\n\n\n<li><span>EXPLAIN FUNCTION can return query plans for embedded SQL++ statements.<\/span><\/li>\n\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><\/h4>\n\n\n\n<h4 class=\"wp-block-heading\">\u00a0SQL++ executed by the N1QL() function call<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span>SQL++ can also be executed by passing a statement in the form of a string as an argument to the N1QL() function.<\/span><\/li>\n\n\n<li><span>When parsing the function for potential SQL++ statements to run the EXPLAIN on, it is difficult to get the dynamic string in the function argument. This can only be reliably resolved at runtime.<\/span><\/li>\n\n\n<li><span>With this reasoning, EXPLAIN FUNCTION does not return the query plans for SQL++ statements executed via N1QL() calls. But instead returns the line numbers where the N1QL() function calls have been made. This line number is calculated from the beginning of the function definition.<\/span><\/li>\n\n\n<li><span>The user can then map the line numbers in the actual function definition and investigate further.<\/span><\/li>\n\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><span>Example 3 &#8211; EXPLAIN FUNCTION on an external JavaScript function<\/span><\/h3>\n\n\n\n<p><span>Create a JavaScript UDF <em>js2<\/em> in a global library <em>lib1<\/em> via the REST endpoint or via the UI:<\/span><\/p>\n\n\n<p>[crayon lang=&#8221;js&#8221; decode=&#8221;true&#8221;]function js2() {<br \/>\n    \/\/ SQL++ executed by a N1QL() function call<br \/>\n    var query1 = N1QL(&#8220;UPDATE default:`travel-sample` SET test = 1 LIMIT 1&#8221;);<\/p>\n<p>    \/\/ Embedded SQL++<br \/>\n    var query2 = SELECT * FROM default:`travel-sample` LIMIT 1;<\/p>\n<p>    var res = [];<br \/>\n    for (const row of query2) {<br \/>\n        res.push(row);<br \/>\n    }<br \/>\n    query2.close()<\/p>\n<p>    return res;<br \/>\n}<br \/>\n[\/crayon]<\/p>\n\n\n\n<p><span> Create the corresponding SQL++ function:<\/span><\/p>\n\n\n<p>[crayon lang=&#8221;default&#8221; decode=&#8221;true&#8221;]CREATE FUNCTION js2() LANGUAGE JAVASCRIPT AS &#8220;js2&#8221; AT &#8220;lib1&#8221;;[\/crayon]<\/p>\n\n\n\n<p><span> Run EXPLAIN FUNCTION on the SQL++ function:<\/span><\/p>\n\n\n\n<p><p>[crayon nums=&#8221;false&#8221; lang=&#8221;default&#8221; decode=&#8221;true&#8221;]CREATE FUNCTION js1() LANGUAGE JAVASCRIPT AS &#8220;js1&#8221; AT &#8220;lib1&#8221;;[\/crayon]<\/p>\n0<\/p>\n\n\n\n<p><span>The results of the above statement will contain:<\/span><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><b>function<\/b><span>\u00a0&#8211; The name of the function EXPLAIN FUNCTION was run on.<\/span><\/li>\n\n\n<li><b>line_numbers<\/b><span>\u00a0&#8211; An array of line numbers calculated from the beginning of the JavaScript function definition where there are N1QL() function calls.<\/span><\/li>\n\n\n<li><b>plans<\/b><span>\u00a0&#8211; An array of plan information that contains an entry for every <\/span><i><span>embedded<\/span><\/i><span> SQL++ statement within the JavaScript UDF.<\/span><\/li>\n\n<\/ol>\n\n\n\n<p><p>[crayon nums=&#8221;false&#8221; lang=&#8221;default&#8221; decode=&#8221;true&#8221;]CREATE FUNCTION js1() LANGUAGE JAVASCRIPT AS &#8220;js1&#8221; AT &#8220;lib1&#8221;;[\/crayon]<\/p>\n1<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Constraints<\/h3>\n\n\n\n<p><span>If the N1QL() function has been aliased in a JavaScript function definition, EXPLAIN FUNCTION will not be able to return the line numbers where this aliased function was called. For example:<\/span><\/p>\n\n\n\n<p><p>[crayon nums=&#8221;false&#8221; lang=&#8221;default&#8221; decode=&#8221;true&#8221;]CREATE FUNCTION js1() LANGUAGE JAVASCRIPT AS &#8220;js1&#8221; AT &#8220;lib1&#8221;;[\/crayon]<\/p>\n2<\/p>\n\n\n\n<p><span>If the UDF contains nested UDF executions, EXPLAIN FUNCTION does not support generating the query plans of SQL++ statements within these nested UDFs.<\/span><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Summary<\/h2>\n\n\n\n<p>Couchbase 7.6 introduces new features for UDF debuggability which will help users peek into UDF execution easily.<\/p>\n\n\n\n<p>Reference the following documentation links to learn more, or check out the other Couchbase 7.6 innovations:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.couchbase.com\/blog\/couchbase-server-7-6-top-developer-features\/\">Couchbase Server 7.6 Features That Developers Will Love<\/a><\/li>\n\n\n<li><a href=\"https:\/\/docs.couchbase.com\/server\/current\/n1ql\/n1ql-language-reference\/userfun.html\">User Defined Functions<\/a><\/li>\n\n\n<li><a href=\"https:\/\/docs.couchbase.com\/server\/current\/n1ql\/n1ql-language-reference\/createfunction.html#create-function-inline\"> Inline UDFs<\/a><\/li>\n\n\n<li><span><a href=\"https:\/\/docs.couchbase.com\/server\/current\/javascript-udfs\/javascript-functions-with-couchbase.html\">A guide to JavaScript UDFs<\/a><\/span><\/li>\n\n\n<li><a href=\"https:\/\/docs.couchbase.com\/server\/current\/n1ql\/n1ql-language-reference\/createfunction.html#create-function-external\">Creating an external UDF<\/a><\/li>\n\n\n<li><a href=\"https:\/\/www.couchbase.com\/blog\/from-n1ql-to-javascript-and-back-part-1-introduction\/\">Blog series on JavaScript UDFs<\/a><\/li>\n\n\n<li><a href=\"https:\/\/docs.couchbase.com\/server\/current\/n1ql\/n1ql-language-reference\/explain.html\">Couchbase SQL++ EXPLAIN statement<\/a><\/li>\n\n<\/ul>\n\n\n\n<p>\u00a0<\/p>\n","protected":false},"excerpt":{"rendered":"<p>User-defined functions (UDFs) are a very useful feature supported in SQL++.\u00a0Couchbase 7.6 introduces improvements that allow for more debuggability and visibility into UDF execution. This blog will explore two new features in Couchbase 7.6 in the world of UDFs. The examples in this post require the travel-sample dataset to be installed. Profiling SQL++ Executed in [&hellip;]<\/p>\n","protected":false},"author":85183,"featured_media":3470,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[136,54,775,163,18],"tags":[800,819,820,682],"ppma_author":[821],"class_list":["post-3473","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-best-practices-and-tutorials","category-couchbase-server","category-engineering","category-javascript","category-n1ql-query","tag-couchbase-7-6","tag-debug","tag-profiling","tag-udf"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.6 (Yoast SEO v27.6) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Debuggability for SQL++ UDFs Improved in Couchbase 7.6<\/title>\n<meta name=\"description\" content=\"Couchbase 7.6 introduces new features to debug user-defined functions (UDFs) which will help users peek into execution easily. Learn about them here.\" \/>\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\/pt\/improved-debuggability-for-sql-user-defined-functions\/\" \/>\n<meta property=\"og:locale\" content=\"pt_BR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Improved Debuggability for SQL++ User-Defined Functions\" \/>\n<meta property=\"og:description\" content=\"Couchbase 7.6 introduces new features to debug user-defined functions (UDFs) which will help users peek into execution easily. Learn about them here.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/pt\/improved-debuggability-for-sql-user-defined-functions\/\" \/>\n<meta property=\"og:site_name\" content=\"The Couchbase Blog\" \/>\n<meta property=\"article:published_time\" content=\"2024-04-05T16:33:32+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/5\/2026\/05\/Screenshot-2024-04-05-at-10.36.07-AM.png\" \/>\n\t<meta property=\"og:image:width\" content=\"2868\" \/>\n\t<meta property=\"og:image:height\" content=\"1574\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Dhanya Gowrish, Software Engineer\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Dhanya Gowrish, Software Engineer\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/es\\\/improved-debuggability-for-sql-user-defined-functions\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/es\\\/improved-debuggability-for-sql-user-defined-functions\\\/\"},\"author\":{\"name\":\"Dhanya Gowrish, Software Engineer\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/person\\\/1515ea2da3d43fe576990a63041fbd73\"},\"headline\":\"Improved Debuggability for SQL++ User-Defined Functions\",\"datePublished\":\"2024-04-05T16:33:32+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/es\\\/improved-debuggability-for-sql-user-defined-functions\\\/\"},\"wordCount\":1731,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/es\\\/improved-debuggability-for-sql-user-defined-functions\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/5\\\/2026\\\/05\\\/Screenshot-2024-04-05-at-10.36.07-AM.png\",\"keywords\":[\"Couchbase 7.6\",\"debug\",\"profiling\",\"User Defined Function (UDF)\"],\"articleSection\":[\"Best Practices and Tutorials\",\"Couchbase Server\",\"Engineering\",\"JavaScript\",\"SQL++ \\\/ N1QL Query\"],\"inLanguage\":\"pt-BR\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/es\\\/improved-debuggability-for-sql-user-defined-functions\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/es\\\/improved-debuggability-for-sql-user-defined-functions\\\/\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/es\\\/improved-debuggability-for-sql-user-defined-functions\\\/\",\"name\":\"Debuggability for SQL++ UDFs Improved in Couchbase 7.6\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/es\\\/improved-debuggability-for-sql-user-defined-functions\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/es\\\/improved-debuggability-for-sql-user-defined-functions\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/5\\\/2026\\\/05\\\/Screenshot-2024-04-05-at-10.36.07-AM.png\",\"datePublished\":\"2024-04-05T16:33:32+00:00\",\"description\":\"Couchbase 7.6 introduces new features to debug user-defined functions (UDFs) which will help users peek into execution easily. Learn about them here.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/es\\\/improved-debuggability-for-sql-user-defined-functions\\\/#breadcrumb\"},\"inLanguage\":\"pt-BR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/es\\\/improved-debuggability-for-sql-user-defined-functions\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-BR\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/es\\\/improved-debuggability-for-sql-user-defined-functions\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/5\\\/2026\\\/05\\\/Screenshot-2024-04-05-at-10.36.07-AM.png\",\"contentUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/5\\\/2026\\\/05\\\/Screenshot-2024-04-05-at-10.36.07-AM.png\",\"width\":2868,\"height\":1574},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/es\\\/improved-debuggability-for-sql-user-defined-functions\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Improved Debuggability for SQL++ User-Defined Functions\"}]},{\"@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\":\"pt-BR\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#organization\",\"name\":\"The Couchbase Blog\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-BR\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/5\\\/2026\\\/06\\\/logo.svg\",\"contentUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/5\\\/2026\\\/06\\\/logo.svg\",\"width\":\"1024\",\"height\":\"1024\",\"caption\":\"The Couchbase Blog\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/person\\\/1515ea2da3d43fe576990a63041fbd73\",\"name\":\"Dhanya Gowrish, Software Engineer\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-BR\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/67a915053133550a9394ff6d71938686c80470af6dddcd21f338c0628391587b?s=96&d=mm&r=ga5a2e3411b913dbfa72531ced00c6307\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/67a915053133550a9394ff6d71938686c80470af6dddcd21f338c0628391587b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/67a915053133550a9394ff6d71938686c80470af6dddcd21f338c0628391587b?s=96&d=mm&r=g\",\"caption\":\"Dhanya Gowrish, Software Engineer\"},\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/pt\\\/author\\\/dhanyagowrish\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Debuggability for SQL++ UDFs Improved in Couchbase 7.6","description":"Couchbase 7.6 introduces new features to debug user-defined functions (UDFs) which will help users peek into execution easily. Learn about them here.","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\/pt\/improved-debuggability-for-sql-user-defined-functions\/","og_locale":"pt_BR","og_type":"article","og_title":"Improved Debuggability for SQL++ User-Defined Functions","og_description":"Couchbase 7.6 introduces new features to debug user-defined functions (UDFs) which will help users peek into execution easily. Learn about them here.","og_url":"https:\/\/www.couchbase.com\/blog\/pt\/improved-debuggability-for-sql-user-defined-functions\/","og_site_name":"The Couchbase Blog","article_published_time":"2024-04-05T16:33:32+00:00","og_image":[{"width":2868,"height":1574,"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/5\/2026\/05\/Screenshot-2024-04-05-at-10.36.07-AM.png","type":"image\/png"}],"author":"Dhanya Gowrish, Software Engineer","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Dhanya Gowrish, Software Engineer","Est. reading time":"5 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.couchbase.com\/blog\/es\/improved-debuggability-for-sql-user-defined-functions\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/es\/improved-debuggability-for-sql-user-defined-functions\/"},"author":{"name":"Dhanya Gowrish, Software Engineer","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/1515ea2da3d43fe576990a63041fbd73"},"headline":"Improved Debuggability for SQL++ User-Defined Functions","datePublished":"2024-04-05T16:33:32+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/es\/improved-debuggability-for-sql-user-defined-functions\/"},"wordCount":1731,"commentCount":0,"publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/es\/improved-debuggability-for-sql-user-defined-functions\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/5\/2026\/05\/Screenshot-2024-04-05-at-10.36.07-AM.png","keywords":["Couchbase 7.6","debug","profiling","User Defined Function (UDF)"],"articleSection":["Best Practices and Tutorials","Couchbase Server","Engineering","JavaScript","SQL++ \/ N1QL Query"],"inLanguage":"pt-BR","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/blog\/es\/improved-debuggability-for-sql-user-defined-functions\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/es\/improved-debuggability-for-sql-user-defined-functions\/","url":"https:\/\/www.couchbase.com\/blog\/es\/improved-debuggability-for-sql-user-defined-functions\/","name":"Debuggability for SQL++ UDFs Improved in Couchbase 7.6","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/es\/improved-debuggability-for-sql-user-defined-functions\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/es\/improved-debuggability-for-sql-user-defined-functions\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/5\/2026\/05\/Screenshot-2024-04-05-at-10.36.07-AM.png","datePublished":"2024-04-05T16:33:32+00:00","description":"Couchbase 7.6 introduces new features to debug user-defined functions (UDFs) which will help users peek into execution easily. Learn about them here.","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/es\/improved-debuggability-for-sql-user-defined-functions\/#breadcrumb"},"inLanguage":"pt-BR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/es\/improved-debuggability-for-sql-user-defined-functions\/"]}]},{"@type":"ImageObject","inLanguage":"pt-BR","@id":"https:\/\/www.couchbase.com\/blog\/es\/improved-debuggability-for-sql-user-defined-functions\/#primaryimage","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/5\/2026\/05\/Screenshot-2024-04-05-at-10.36.07-AM.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/5\/2026\/05\/Screenshot-2024-04-05-at-10.36.07-AM.png","width":2868,"height":1574},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/blog\/es\/improved-debuggability-for-sql-user-defined-functions\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Improved Debuggability for SQL++ User-Defined Functions"}]},{"@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":"pt-BR"},{"@type":"Organization","@id":"https:\/\/www.couchbase.com\/blog\/#organization","name":"The Couchbase Blog","url":"https:\/\/www.couchbase.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"pt-BR","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/5\/2026\/06\/logo.svg","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/5\/2026\/06\/logo.svg","width":"1024","height":"1024","caption":"The Couchbase Blog"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/1515ea2da3d43fe576990a63041fbd73","name":"Dhanya Gowrish, Software Engineer","image":{"@type":"ImageObject","inLanguage":"pt-BR","@id":"https:\/\/secure.gravatar.com\/avatar\/67a915053133550a9394ff6d71938686c80470af6dddcd21f338c0628391587b?s=96&d=mm&r=ga5a2e3411b913dbfa72531ced00c6307","url":"https:\/\/secure.gravatar.com\/avatar\/67a915053133550a9394ff6d71938686c80470af6dddcd21f338c0628391587b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/67a915053133550a9394ff6d71938686c80470af6dddcd21f338c0628391587b?s=96&d=mm&r=g","caption":"Dhanya Gowrish, Software Engineer"},"url":"https:\/\/www.couchbase.com\/blog\/pt\/author\/dhanyagowrish\/"}]}},"acf":[],"authors":[{"term_id":821,"user_id":85183,"is_guest":0,"slug":"dhanyagowrish","display_name":"Dhanya Gowrish, Software Engineer","avatar_url":{"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/5\/2026\/05\/dhanyagowrish-couchbase-3.png","url2x":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/5\/2026\/05\/dhanyagowrish-couchbase-3.png"},"0":null,"1":"","2":"","3":"","4":"","5":"","6":"","7":"","8":""}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/posts\/3473","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/users\/85183"}],"replies":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/comments?post=3473"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/posts\/3473\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/media\/3470"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/media?parent=3473"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/categories?post=3473"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/tags?post=3473"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/ppma_author?post=3473"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}