{"id":14562,"date":"2023-06-23T13:15:52","date_gmt":"2023-06-23T20:15:52","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/?p=14562"},"modified":"2024-03-01T09:01:33","modified_gmt":"2024-03-01T17:01:33","slug":"recursive-query-processing-in-sql-n1ql","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/ko\/recursive-query-processing-in-sql-n1ql\/","title":{"rendered":"SQL++\uc758 \uc7ac\uadc0 \ucffc\ub9ac \ucc98\ub9ac(N1QL)"},"content":{"rendered":"<p><span style=\"font-weight: 400\">\ub2e4\uc74c\uacfc \uac19\uc740 \ubb38\uc81c\uac00 \ubc1c\uc0dd\ud588\uc744 \uac00\ub2a5\uc131\uc774 \ub9e4\uc6b0 \ub192\uc2b5\ub2c8\ub2e4. <\/span><b>\uacc4\uce35\uc801 \uc870\ud68c \ub610\ub294 \uadf8\ub798\ud504 \ud0d0\uc0c9<\/b><span style=\"font-weight: 400\"> \uc2e4\uc81c \uc0ac\uc6a9 \uc0ac\ub840\ub97c \ucc98\ub9ac\ud558\ub294 \uac1c\ubc1c\uc790\ub85c\uc11c \uc560\ud50c\ub9ac\ucf00\uc774\uc158\uc5d0 \ub300\ud55c \uace0\ubbfc\uc774 \ub9ce\uc2b5\ub2c8\ub2e4. \uadf8\ub9ac\uace0 \ub2f9\uc5f0\ud55c \uc774\uc720\ub85c \uc774\ub7ec\ud55c \ubb38\uc81c\ub294 <\/span><b>\ud074\ub77c\uc774\uc5b8\ud2b8 \uce21\uc774 \uc544\ub2cc \ub370\uc774\ud130\ubca0\uc774\uc2a4 \uacc4\uce35\uc5d0\uc11c<\/b><span style=\"font-weight: 400\">.<\/span><\/p>\n<h2><span style=\"font-weight: 400\">\uacc4\uce35\uc801 \uc870\ud68c\ub780 \ubb34\uc5c7\uc778\uac00\uc694?<\/span><\/h2>\n<p><span style=\"font-weight: 400\">\uacc4\uce35 \uad6c\uc870 \uc870\ud68c\ub294 \ub2e4\uc74c\uacfc \uac19\uc740 \uacc4\uce35 \uad6c\uc870\uc5d0\uc11c \ub370\uc774\ud130\ub97c \uac80\uc0c9\ud558\uace0 \uac80\uc0c9\ud558\ub294 \ud504\ub85c\uc138\uc2a4\ub97c \ub9d0\ud569\ub2c8\ub2e4. <\/span><b>\ud2b8\ub9ac \ub610\ub294 \ubd80\ubaa8-\uc790\uc2dd \uad00\uacc4<\/b><span style=\"font-weight: 400\">. \uc5ec\uae30\uc5d0\ub294 \uc870\uc9c1\ub3c4, \ud30c\uc77c \uc2dc\uc2a4\ud15c, \uce74\ud14c\uace0\ub9ac \ud2b8\ub9ac\uc640 \uac19\uc740 \ud2b9\uc815 \ub370\uc774\ud130 \uc694\uc18c\ub098 \uad00\ub828 \uc815\ubcf4\ub97c \ucc3e\uae30 \uc704\ud574 \uacc4\uce35 \uad6c\uc870\uc758 \uc218\uc900 \ub610\ub294 \uacc4\uce35\uc744 \ud0d0\uc0c9\ud558\ub294 \uc791\uc5c5\uc774 \ud3ec\ud568\ub429\ub2c8\ub2e4.<\/span><\/p>\n<p><span style=\"font-weight: 400\">\uadf8\ub798\ud504\ub294 \uae30\ubcf8\uc801\uc73c\ub85c \uc8fc\uae30\ub97c \uac00\uc9c8 \uc218 \uc788\ub294 \ud2b8\ub9ac\uc774\ubbc0\ub85c \uc8fc\uae30\ub97c \ucc98\ub9ac\ud560 \uc218 \uc788\ub294 \ucd94\uac00 \uad6c\uc131\uc774 \uc788\ub2e4\uba74 \uacbd\ub85c \ucc3e\uae30 \ub4f1\uc758 \uc0ac\uc6a9 \uc0ac\ub840\ub3c4 \ub2e4\ub8f0 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-14566\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/06\/image_2023-06-23_124236084.png\" alt=\"hierachical lookups\" width=\"1019\" height=\"679\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_124236084.png 1019w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_124236084-300x200.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_124236084-768x512.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_124236084-400x267.png 400w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_124236084-450x300.png 450w\" sizes=\"auto, (max-width: 1019px) 100vw, 1019px\" \/><\/p>\n<p><span style=\"font-weight: 400\">\uacc4\uce35 \uad6c\uc870\uac00 \uc788\ub294 \uc9c1\uc6d0 \uceec\ub809\uc158\uc744 \uc0ac\uc6a9\ud558\ub294 \uc608\ub97c \uc0b4\ud3b4\ubd05\uc2dc\ub2e4. \uc9c1\uc6d0\uc740 \uad00\ub9ac\uc790-\ubd80\ud558 \uad00\uacc4\ub85c \uad6c\uc131\ub429\ub2c8\ub2e4. \uc774 \uc9c1\uc6d0 \uacc4\uce35 \uad6c\uc870\uc5d0 \ub300\ud55c \uc791\uc5c5\uc744 Couchbase\uc640 JavaScript UDF\ub97c \uc0ac\uc6a9\ud558\uc5ec \uc218\ud589\ud558\uc5ec \uc194\ub8e8\uc158\uc744 \uc2dc\uc5f0\ud574 \ubcf4\uaca0\uc2b5\ub2c8\ub2e4.<\/span><\/p>\n<p><span style=\"font-weight: 400\">\uc5d0\uc11c <\/span><i><span style=\"font-weight: 400\">\uc9c1\uc6d0 \uceec\ub809\uc158 <\/span><\/i><span style=\"font-weight: 400\">\uac80\uc0c9\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4:<\/span><\/p>\n<p><span style=\"font-weight: 400\">i) \uc77c\ubc18 \uc9c1\uc6d0 \uc218\uc900:<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-14567\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/06\/image_2023-06-23_124344227-1024x555.png\" alt=\"\" width=\"900\" height=\"488\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_124344227-1024x555.png 1024w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_124344227-300x163.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_124344227-768x416.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_124344227.png 1238w\" sizes=\"auto, (max-width: 900px) 100vw, 900px\" \/><\/p>\n<p><span style=\"font-weight: 400\">ii) \uac01 \uc9c1\uc6d0\uc5d0 \ub300\ud55c \uacc4\uce35 \uad6c\uc870:<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-14568\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/06\/image_2023-06-23_124413697-1024x379.png\" alt=\"\" width=\"900\" height=\"333\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_124413697-1024x379.png 1024w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_124413697-300x111.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_124413697-768x284.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_124413697.png 1296w\" sizes=\"auto, (max-width: 900px) 100vw, 900px\" \/><\/p>\n<h2><span style=\"font-weight: 400\">\uc774 \ube14\ub85c\uadf8\uc5d0\uc11c \ub2e4\ub8e8\ub294 \ub0b4\uc6a9<\/span><\/h2>\n<p><span style=\"font-weight: 400\">\uc815\ub9d0 \uc88b\uc544\ud569\ub2c8\ub2e4. <\/span><b>\uc720\uc5f0\uc131<\/b><span style=\"font-weight: 400\"> \uc758 \uae30\ubcf8 \ub370\uc774\ud130 \ubaa8\ub378\uc740 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4. <\/span><b>JSON, <\/b><span style=\"font-weight: 400\">\uadf8\ub807\uae30 \ub54c\ubb38\uc5d0 \ub370\uc774\ud130\ubca0\uc774\uc2a4 \uc694\uad6c \uc0ac\ud56d\uc744 \uc704\ud574 Couchbase\ub97c \uc120\ud0dd\ud55c \uac83\uc785\ub2c8\ub2e4 (\ud6cc\ub96d\ud55c \uc120\ud0dd\uc785\ub2c8\ub2e4. :-) ).<\/span><\/p>\n<p><span style=\"font-weight: 400\">\uc774\uc81c Couchbase\ub97c \ub370\uc774\ud130\ubca0\uc774\uc2a4\ub85c \uc0ac\uc6a9\ud558\ubbc0\ub85c \uc704\uc5d0\uc11c \uc5b8\uae09\ud55c \ubb38\uc81c\ub97c \ud574\uacb0\ud558\ub824\uace0 \ud569\ub2c8\ub2e4. \uba87 \uac00\uc9c0 \uc870\uc0ac\ub97c \ud55c \ud6c4 <\/span><a href=\"https:\/\/www.couchbase.com\/blog\/ko\/sqlplusplus\/\"><span style=\"font-weight: 400\">SQL++<\/span><\/a><span style=\"font-weight: 400\"> \uc5b8\uc5b4 \ucc38\uc870 \ubb38\uc11c<\/span><span style=\"font-weight: 400\"> \uc774 \uc5c6\ub2e4\ub294 \uacb0\ub860\uc5d0 \ub3c4\ub2ec\ud588\uc2b5\ub2c8\ub2e4. <\/span><i><span style=\"font-weight: 400\">\uc131\uba85\uc11c <\/span><\/i><span style=\"font-weight: 400\">\ub610\ub294 <\/span><i><span style=\"font-weight: 400\">\uae30\ub2a5 <\/span><\/i><span style=\"font-weight: 400\">\uc640 \uac19\uc740 \ubb38\uc81c\ub97c \ud574\uacb0\ud558\uae30 \uc704\ud574 SQL++\uc758 <\/span><a href=\"https:\/\/www.mongodb.com\/docs\/manual\/reference\/operator\/aggregation\/graphLookup\/?_ga=2.234064094.1723037650.1675387315-1783168968.1675058199#-graphlookup--aggregation-\"><span style=\"font-weight: 400\">\uadf8\ub798\ud504 \uc870\ud68c<\/span><\/a><span style=\"font-weight: 400\"> MongoDB\uc758 API \ub610\ub294 <\/span><a href=\"https:\/\/docs.snowflake.com\/en\/user-guide\/queries-cte#recursive-ctes-and-hierarchical-data\"><span style=\"font-weight: 400\">\uc7ac\uadc0\uc801 CTE<\/span><\/a><span style=\"font-weight: 400\"> \ub97c SQL \ub370\uc774\ud130\ubca0\uc774\uc2a4\uc5d0 \uc800\uc7a5\ud569\ub2c8\ub2e4.<\/span><\/p>\n<p><span style=\"font-weight: 400\">\ud558\uc9c0\ub9cc <\/span><b>\uae30\uc874 \uc778\ud504\ub77c\ub97c \ud1b5\ud574 \uc0ac\uc6a9\uc790\ub294 \uc790\ubc14\uc2a4\ud06c\ub9bd\ud2b8 UDF\ub97c \uc0ac\uc6a9\ud558\uc5ec \uc7ac\uadc0\uc801 CTE\ub97c \uc5d0\ubbac\ub808\uc774\uc158\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. <\/b><span style=\"font-weight: 400\">\ub2e4\uc74c \uc139\uc158\uc5d0\uc11c\ub294 \uc774\ub97c \uc218\ud589\ud558\ub294 \ubc29\ubc95\uacfc \uadf8 \uc774\uc0c1\uc744 \uc124\uba85\ud569\ub2c8\ub2e4!<\/span><\/p>\n<h2><span style=\"font-weight: 400\">\uc7ac\uadc0 \ucffc\ub9ac\uc5d0 \ub300\ud55c \uc194\ub8e8\uc158<\/span><\/h2>\n<p><span style=\"font-weight: 400\">\uc774 \uc194\ub8e8\uc158\uc744 \uad6c\ud604\ud558\ub824\uba74 \ud3ed \uc6b0\uc120 \uac80\uc0c9 \uc54c\uace0\ub9ac\uc998\uc744 \uc0ac\uc6a9\ud558\uc5ec \uc9c1\uc6d0 \uacc4\uce35\uc744 \ud0d0\uc0c9\ud558\ub294 JavaScript UDF\ub97c \ub9cc\ub4e4\uc5b4\uc57c \ud569\ub2c8\ub2e4. UDF\ub294 <\/span><b>\uc575\ucee4 \ucffc\ub9ac<\/b><span style=\"font-weight: 400\">, a <\/span><b>\uc7ac\uadc0 \ucffc\ub9ac<\/b><span style=\"font-weight: 400\">\ubc0f <\/span><b>\ub9e4\uac1c\ubcc0\uc218\ub85c \uad6c\uc131 \uc635\uc158<\/b><span style=\"font-weight: 400\">. \uc575\ucee4 \ucffc\ub9ac\ub294 \ucd08\uae30 \uc9c1\uc6d0 \uc9d1\ud569\uc744 \uac80\uc0c9\ud558\ub294 \ubc18\uba74 \uc7ac\uadc0 \ucffc\ub9ac\ub294 \uc774\uc804 \ubc18\ubcf5\uc758 \uacb0\uacfc\ub97c <\/span><i><span style=\"font-weight: 400\">$1<\/span><\/i><span style=\"font-weight: 400\"> \ub9e4\uac1c\ubcc0\uc218\ub97c \uc0ac\uc6a9\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \uad6c\uc131 \uc635\uc158\uc744 \uc0ac\uc6a9\ud558\uba74 \uc870\uae30 \uc885\ub8cc \uae30\uc900, \ub0b4\ubd80 \ucffc\ub9ac\uc5d0 \ub300\ud55c \uc778\uc218, \uc8fc\uae30 \uac10\uc9c0, \ucffc\ub9ac \uacc4\ud68d \uc124\uba85 \ubaa8\ub4dc, \ub85c\uae45 \uc635\uc158 \ub4f1\uc758 \uc0ac\uc6a9\uc790 \uc9c0\uc815\uc774 \uac00\ub2a5\ud569\ub2c8\ub2e4.<\/span><\/p>\n<h3>\ub0b4\ubd80 \ucffc\ub9ac \uc0ac\uc6a9 \ubc29\ubc95<\/h3>\n<p><span style=\"font-weight: 400\">\uc575\ucee4 \ucffc\ub9ac\ub294 <\/span><b>\ub8e8\ud2b8 \uc218\uc900 \ubb38\uc11c<\/b><span style=\"font-weight: 400\"> \ub97c \ub300\uc0c1 \uceec\ub809\uc158\uc5d0\uc11c \uc81c\uac70\ud569\ub2c8\ub2e4.<\/span><\/p>\n<p><span style=\"font-weight: 400\">\uc7ac\uadc0 \ucffc\ub9ac\ub294 <\/span><i><span style=\"font-weight: 400\">JOIN <\/span><\/i><span style=\"font-weight: 400\">\uc808\uc758 \ud55c \ucabd\uc744 <\/span><i><span style=\"font-weight: 400\">$1<\/span><\/i><span style=\"font-weight: 400\"> \uc640 \ub2e4\ub978 \ud558\ub098\ub97c \ub300\uc0c1 \uceec\ub809\uc158\uc73c\ub85c \uc9c0\uc815\ud558\uc5ec \ubd80\ubaa8-\uc790\uc2dd \uad00\uacc4\ub97c \uc545\uc6a9\ud558\uace0 \ud55c \uc218\uc900\uc5d0\uc11c \ub2e4\ub978 \uc218\uc900\uc73c\ub85c \uc774\ub3d9\uc744 \uc218\ud589\ud569\ub2c8\ub2e4.<\/span><\/p>\n<p><span style=\"font-weight: 400\">\uae30\ub2a5\uc5d0\uc11c, <\/span><i><span style=\"font-weight: 400\">$1<\/span><\/i><span style=\"font-weight: 400\"> \ub294 \uc7ac\uadc0\uc801 CTE\uc5d0\uc11c CTE \ubcc4\uce6d\uc774 \uc218\ud589\ud558\ub294 \uc791\uc5c5\uc744 \uc218\ud589\ud569\ub2c8\ub2e4.<\/span><\/p>\n<p><span style=\"font-weight: 400\">JavaScript UDF \ub0b4\uc5d0\uc11c SQL++(N1QL)\uc744 \uc0ac\uc6a9\ud558\ub294 \ubc29\ubc95\uc744 \ub354 \uc798 \uc774\ud574\ud558\ub824\uba74 \ub2e4\uc74c\uc744 \uc0b4\ud3b4\ubcf4\uc138\uc694.<\/span> <a href=\"https:\/\/www.couchbase.com\/blog\/ko\/from-n1ql-to-javascript-and-back-part-1-introduction\/\"><span style=\"font-weight: 400\">N1QL\uc5d0\uc11c JavaScript\ub85c, \uadf8\ub9ac\uace0 \ub2e4\uc2dc<\/span><\/a><span style=\"font-weight: 400\">.<\/span><\/p>\n<p><span style=\"font-weight: 400\">\uc774\uc81c \ud504\ub85c\uc138\uc2a4\ub97c \ub2e8\uacc4\ubcc4\ub85c \uc0b4\ud3b4\ubcf4\uaca0\uc2b5\ub2c8\ub2e4. \uc6b0\uc120 <\/span><b>\uc7ac\uadc0 \ucffc\ub9ac \ucc98\ub9ac\uac00 \uc815\ub9d0 \uc7ac\uadc0 \ud568\uc218\uc5ec\uc57c \ud558\ub098\uc694?<\/b><\/p>\n<p><span style=\"font-weight: 400\">\uc544\ub2c8\uc694, \uc2dc\uac04 \ubcf5\uc7a1\uc131(\uc7ac\uadc0\uc5d0\uc11c\ub294 \ub3d9\uc77c\ud55c \uae30\ub2a5\uc774 \uae30\ud558\uae09\uc218\uc801\uc774\uc9c0\ub9cc \ubc18\ubcf5 \uc811\uadfc \ubc29\uc2dd\uc5d0\uc11c\ub294 \uc120\ud615\uc801\uc77c \uc218 \uc788\uc74c)\uacfc \uc7ac\uadc0\uc640 \ud568\uaed8 \ubc1c\uc0dd\ud558\ub294 \ud504\ub808\uc784 \ub4f1\uc758 \ub2e4\ub978 \ubaa8\ub4e0 \ubb38\uc81c\ub97c \uace0\ub824\ud560 \ub54c \uc774\uac83\uc740 \ub098\uc05c \uc120\ud0dd\uc785\ub2c8\ub2e4. \uad00\uc2ec\uc774 \uc788\uc73c\uc2dc\ub2e4\uba74 \ub2e4\uc74c\uc744 \ud655\uc778\ud574 \ubcf4\uc138\uc694. <\/span><a href=\"https:\/\/www.baeldung.com\/cs\/convert-recursion-to-iteration\"><span style=\"font-weight: 400\">\uae30\uc0ac<\/span><\/a><span style=\"font-weight: 400\"> \ub97c \uc0ac\uc6a9\ud558\uc5ec \ud14c\uc77c \uc7ac\uadc0 \ud568\uc218\ub97c \ubc18\ubcf5\uc73c\ub85c \ubcc0\ud658\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \ub610\ud55c JS UDF\uc5d0\ub294 \uc0ac\uc804 \uc124\uc815\ub41c <\/span><b>\ucd5c\ub300 \uc7ac\uadc0 \uae4a\uc774\ub294 128\uc785\ub2c8\ub2e4;<\/b><span style=\"font-weight: 400\"> \uc774\ub294 \uc6b0\ub9ac\uac00 \ud558\ub824\ub294 \uc77c\uc5d0 \ubc14\ub78c\uc9c1\ud558\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4. <\/span><\/p>\n<p><span style=\"font-weight: 400\">\uac04\ub2e8\ud788 \ub9d0\ud574, \ubaa8\ub4e0 \ubc18\ubcf5 \uc791\uc5c5\uc740 \ub2e4\uc74c\uc744 \uc218\ud589\ud569\ub2c8\ub2e4:<\/span><span style=\"font-weight: 400\"><br \/>\n<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-14569\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/06\/image_2023-06-23_124659049-1024x439.png\" alt=\"\" width=\"900\" height=\"386\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_124659049-1024x439.png 1024w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_124659049-300x129.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_124659049-768x330.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_124659049.png 1235w\" sizes=\"auto, (max-width: 900px) 100vw, 900px\" \/><\/p>\n<p><span style=\"font-weight: 400\">\uc800\ud76c\ub294 \uc774 \uc810\uc744 \uc778\uc815\ud558\uace0 \uc2f6\uc2b5\ub2c8\ub2e4. <\/span><a href=\"https:\/\/www.postgresql.org\/docs\/current\/queries-with.html\"><span style=\"font-weight: 400\">\uae30\uc0ac<\/span><\/a><span style=\"font-weight: 400\"> \uc758 \uc811\uadfc \ubc29\uc2dd\uc5d0 \ub300\ud574 \uc124\uba85\ud569\ub2c8\ub2e4.<\/span><\/p>\n<h2><span style=\"font-weight: 400\">\uace0\ub824\ud574\uc57c \ud560 \uc0ac\ud56d<\/span><\/h2>\n<p><span style=\"font-weight: 400\">\uc5b4\ub5bb\uac8c <\/span><b>\uc0c1\ud0dc \ud45c\ud604\uc2dd<\/b><span style=\"font-weight: 400\"> \ub97c \uc0dd\uc131\ud558\uace0 \ucffc\ub9ac\uc5d0 \ub9e4\uac1c \ubcc0\uc218\ub85c \uc804\ub2ec\ud560 \uc218 \uc788\ub098\uc694(\uc5ec\uae30\uc11c\ub294 \uc7ac\uadc0\uc801\uc778 \ubd80\ubd84)?<\/span><\/p>\n<ul>\n<li style=\"list-style-type: none\">\n<ul>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">SQL++ \uae30\ub2a5\uc744 \uc0ac\uc6a9\ud558\uc5ec <\/span><a href=\"https:\/\/docs.couchbase.com\/server\/current\/n1ql\/n1ql-intro\/queriesandresults.html#named-placeholders\"><span style=\"font-weight: 400\">\ub3d9\uc801 \ucffc\ub9ac \ub9e4\uac1c \ubcc0\uc218<\/span><\/a><span style=\"font-weight: 400\"> \ub9e4\uac1c\ubcc0\uc218\ud654\ub41c \ucffc\ub9ac\ub97c \uc0ac\uc6a9\ud558\uc5ec \uc5ec\ub7ec \ub808\ubca8\uc5d0 \uac78\uccd0 \uc0c1\ud0dc \uac12\uc744 \uc720\uc9c0\ud569\ub2c8\ub2e4.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">\ub2f9\uc0ac\ub294 \ub2e4\uc74c\uc744 \uc0ac\uc6a9\ud569\ub2c8\ub2e4. <\/span><em>$1<\/em> \ub97c \uc7ac\uadc0 \uc808\uc5d0 \uc0ac\uc6a9\ud558\uc5ec \uc774\uc804 \ubc18\ubcf5 \uacb0\uacfc, \uc989 \uc0c1\ud0dc \ud45c\ud604\uc2dd\uc744 \ucc38\uc870\ud569\ub2c8\ub2e4.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><strong>\uc5b4\ub5bb\uac8c \ucd5c\uc801\ud654\ud560 \uc218 \uc788\uc744\uae4c\uc694?<\/strong><\/p>\n<ul>\n<li style=\"list-style-type: none\">\n<ul>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">\uc2e4\ud589 \uc2dc\uc810\uc5d0 \ucffc\ub9ac \uacc4\ud68d\uc744 \uc7ac\uc0ac\uc6a9\ud560 \uc218 \uc788\ub3c4\ub85d \uc575\ucee4 \ucffc\ub9ac\uc640 \uc7ac\uadc0 \ucffc\ub9ac\ub97c \ubaa8\ub450 \ucc98\uc74c\uc5d0 \uc900\ube44\ud569\ub2c8\ub2e4.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">\ucffc\ub9ac \uacc4\ud68d\uc744 \ubcf4\ub294 \ubc29\ubc95 \ucc3e\uae30( <\/span><i><span style=\"font-weight: 400\">\uc124\uba85<\/span><\/i><span style=\"font-weight: 400\"> \ubb38)\uc744 \uc0ac\uc6a9\ud558\uc5ec \ub0b4\ubd80 \ubb38(\uc575\ucee4 \ubc0f \uc7ac\uadc0)\uc5d0 \uc801\uc808\ud55c \uc778\ub371\uc2a4\ub97c \uc0dd\uc131\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/span><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\uad6c\ud604\uc5d0 \ub300\ud55c \uac1c\uad04\uc801\uc778 \uac1c\uc694\ub294 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-14570\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/06\/image_2023-06-23_124838894-1024x659.png\" alt=\"\" width=\"900\" height=\"579\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_124838894-1024x659.png 1024w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_124838894-300x193.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_124838894-768x494.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_124838894.png 1294w\" sizes=\"auto, (max-width: 900px) 100vw, 900px\" \/><\/p>\n<h3><span style=\"font-weight: 400\">JS UDF\ub97c \uc0ac\uc6a9\ud55c \uc7ac\uadc0\uc801 CTE \ucf54\ub4dc\u00a0<\/span><\/h3>\n<p><span style=\"font-weight: 400\">\uc774\uac83\uc740 \uc2dc\uc791\ud558\uace0 \uc2e4\ud589\ud558\uae30\uc5d0 \ub9e4\uc6b0 \uc21c\uc9c4\ud55c \uad6c\ud604\uc785\ub2c8\ub2e4. \uc6b0\ub9ac\ub294 <em>\ubc94\uc704 \uc6b0\uc120 \uac80\uc0c9<\/em> \uc54c\uace0\ub9ac\uc998\uc744 \uc0ac\uc6a9\ud558\uc5ec \uc704\uc758 \uac1c\uc694\uc5d0 \ub530\ub77c \uc8fc\ubb38\uc758 \ud750\ub984\uc744 \uc124\uc815\ud569\ub2c8\ub2e4. \ucf54\ub4dc\ub294 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4. <\/span><a href=\"https:\/\/gist.github.com\/GauravJayaraj\/2d290f5398efe6edb8dc1b53e87556ae\"><span style=\"font-weight: 400\">\uc774 \uc694\uc810<\/span><\/a><span style=\"font-weight: 400\"> \ub9c1\ud06c:<\/span><\/p>\n<pre class=\"height-set:true nums:false lang:js decode:true\">function recursive_cte(anchor , recursive, config) {\r\n    let isLog = false;\r\n    let anchorArgs=[];\r\n    let recursiveArgs=[];\r\n    let cycleFields=[];\r\n    let hash;    \r\n    let levelLimit = -1;\r\n    let isExplain = false;\r\n\r\n    let res = {\"res\":[], \"log\":[]}\r\n\r\n\r\n    if(config!=undefined) {\r\n        if(config.log!=undefined &amp;&amp; config.log==true) {\r\n            isLog = true;\r\n        }\r\n\r\n        if(config.anchorArgs!=undefined) {\r\n            anchorArgs = config.anchorArgs;\r\n        }\r\n\r\n        if(config.recursiveArgs!=undefined) {\r\n            recursiveArgs = config.recursiveArgs;\r\n        }\r\n\r\n        if(config.levelLimit!=undefined &amp;&amp; config.levelLimit&gt;0) {\r\n            levelLimit = config.levelLimit;\r\n        }\r\n\r\n        if(config.cycleFields!=undefined &amp;&amp; config.cycleFields.length&gt;0) {\r\n            res['log'].push(\"Got cycle fields \"+ config.cycleFields)\r\n            \/\/ for(const field of config.cycleFields) {\r\n            \/\/     cycleFields.push(field);\r\n            \/\/ }\r\n            cycleFields = config.cycleFields;\r\n            res['log'].push(cycleFields);\r\n            \/\/ init hash\r\n            hash = createhash();\r\n\r\n        }\r\n\r\n        if(config.explain!=undefined) {\r\n            isExplain = true;\r\n        }\r\n\r\n    }\r\n    \r\n\r\n    \/\/ init state\r\n    recursiveArgs.push(0);\r\n    \r\n    \/\/ Prepare anchor statement\r\n    let anchorPname;\r\n    let anchorPlan;\r\n    try{\r\n        const anchor_prep = N1QL(\"PREPARE FORCE \"+anchor);\r\n        \r\n        for(const ap of anchor_prep) {\r\n            anchorPname = ap[\"name\"];\r\n            anchorPlan = ap[\"operator\"];\r\n        }\r\n\r\n        res['log'].push(\"prepared anchor\");\r\n    }\r\n    catch(err) {\r\n        res['log'].push(\"couldn't prepare anchor\");\r\n        throw err;\r\n    }\r\n\r\n     \/\/ prepare recursive statement\r\n\r\n     let recursivePname;\r\n     let recursivePlan;\r\n     try{\r\n         const recursive_prep = N1QL(\"PREPARE FORCE \"+recursive);\r\n \r\n         for(const rp of recursive_prep) {\r\n             recursivePname = rp[\"name\"];\r\n             recursivePlan = rp[\"operator\"];\r\n         }\r\n         res['log'].push(\"prepared recursive\");\r\n     }\r\n     catch(err) {\r\n         res['log'].push(\"couldn't prepare recursive\");\r\n         throw err;\r\n     }\r\n\r\n\r\n    \/\/ state expression \r\n    let workSet = []\r\n\r\n    \/\/ execute anchor \r\n    try{\r\n        const anchorExec = N1QL(\"EXECUTE `\"+anchorPname+\"`\",anchorArgs);\r\n        for(const doc of anchorExec) {\r\n            workSet.push(doc);\r\n        }\r\n    }\r\n    catch(err) {\r\n        res['log'].push(\"failed to execute anchor\");\r\n        throw err;\r\n    }\r\n\r\n    \/\/ cycle check\r\n    if(cycleFields.length&gt;0) {\r\n        res['log'].push(\"cycle check on fields \"+cycleFields)\r\n        workSet = cycleCheck(cycleFields, hash, workSet);\r\n    }\r\n\r\n    \/\/ populate root level( level 0 )\r\n    res['res'].push(...workSet);\r\n\r\n\r\n    let level = 0;\r\n\r\n    while(workSet.length!=0) {\r\n\r\n        \/\/ exit on level condition\r\n        if(levelLimit&gt;0 &amp;&amp; level&gt;=levelLimit) {\r\n            res['log'].push(\"Exit on level condition: levelLimit=\"+levelLimit.toString())\r\n            break;\r\n        }\r\n\r\n        \/\/ execute recursive query\r\n        let newWorkSet = []\r\n\r\n        \/\/ set state $1\r\n        recursiveArgs[0] = workSet;\r\n\r\n        try{\r\n            const recursiveExec = N1QL(\"EXECUTE `\"+recursivePname+\"`\", recursiveArgs)\r\n\r\n            \/\/ empty workSet to populate again\r\n            for(const doc of recursiveExec) {\r\n                newWorkSet.push(doc)\r\n            }\r\n        }\r\n        catch(err){\r\n            res['log'].push(\"failed execute recursive\");\r\n            throw err;\r\n        }\r\n\r\n        \/\/ cycle check\r\n        if(cycleFields.length&gt;0) {\r\n            newWorkSet = cycleCheck(cycleFields, hash, newWorkSet);\r\n        }\r\n\r\n        if(newWorkSet.length==0)\r\n            break;\r\n\r\n        \r\n        res[\"res\"].push(...newWorkSet);\r\n\r\n        \/\/ update state expression\r\n        workSet = newWorkSet;\r\n\r\n        level++;\r\n    }\r\n\r\n    if(isExplain){\r\n        res['log'].push(\"Anchor Plan:\");\r\n        res['log'].push(anchorPlan);\r\n        res['log'].push(\"Recursive Plan\");\r\n        res[\"log\"].push(recursivePlan);\r\n        return res;\r\n    }\r\n\r\n    return isLog?res:res['res'];\r\n}\r\n\r\n\r\nfunction createhash() {\r\n    let h = {};\r\n\r\n    const getVal = function(key) {\r\n        return h[key]==undefined?false:true;\r\n    }\r\n\r\n    const setVal = function(key) {\r\n        h[key] = true;\r\n    }\r\n\r\n    return {setVal, getVal};\r\n}\r\n\r\nfunction cycleCheck(cycleFields, hash, workSet) {\r\n    let cycleTrim = [];\r\n    for(const doc of workSet) {\r\n        let key = [];\r\n        for(const field of cycleFields) {\r\n            if(doc[field]!=undefined){\r\n                key.push(String(doc[field]));\r\n            }\r\n        }\r\n\r\n        \/\/ create hashKey\r\n        hashKey = key.join(String.fromCharCode(30));\r\n\r\n\r\n        if(hash.getVal(hashKey)==true){\r\n            continue;\r\n        }\r\n        else{\r\n            hash.setVal(hashKey);\r\n            cycleTrim.push(doc);\r\n        }\r\n    }\r\n\r\n    return cycleTrim;\r\n}\r\n<\/pre>\n<h3>\uae30\ub2a5 \ucd94\uac00 \ubc29\ubc95<\/h3>\n<p><span style=\"font-weight: 400\">\ub2e4\uc74c\uc740 <\/span><a href=\"https:\/\/docs.couchbase.com\/server\/current\/guides\/create-javascript-library.html\"><span style=\"font-weight: 400\">\ub9c1\ud06c<\/span><\/a><span style=\"font-weight: 400\"> \ub97c \uc0ac\uc6a9\ud558\uc5ec \uc790\ubc14\uc2a4\ud06c\ub9bd\ud2b8 \ub77c\uc774\ube0c\ub7ec\ub9ac\uc5d0 \ucd94\uac00\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4(\uc608 <\/span><em>\"mylibrary\"<\/em><span style=\"font-weight: 400\">), \ucffc\ub9ac \uc11c\ube44\uc2a4 \ub0b4\uc5d0\uc11c <\/span><a href=\"https:\/\/docs.couchbase.com\/server\/current\/guides\/create-user-defined-function.html\"><span style=\"font-weight: 400\">\ub9c1\ud06c<\/span><\/a><span style=\"font-weight: 400\"> \ub97c \ud074\ub9ad\ud558\uc5ec \ucd94\uac00\ub41c \ub77c\uc774\ube0c\ub7ec\ub9ac\uc5d0\uc11c UDF\ub97c \uc0dd\uc131\ud569\ub2c8\ub2e4.<\/span><\/p>\n<p><span style=\"font-weight: 400\">SQL++\ub97c \uc0ac\uc6a9\ud558\uc5ec \ub77c\uc774\ube0c\ub7ec\ub9ac\uc5d0\uc11c UDF\ub97c \uc0dd\uc131\ud569\ub2c8\ub2e4: <\/span><span style=\"font-weight: 400\"><br \/>\n<\/span><\/p>\n<pre class=\"lang:default decode:true\">CREATE FUNCTION recursiveCte(\uc575\ucee4, \ub9ac\ucee4\uc2dc\ube0c, \uad6c\uc131)\r\n\uc5b8\uc5b4 \uc790\ubc14\uc2a4\ud06c\ub9bd\ud2b8 \"recursive_cte\" AT \"mylibrary\";\r\n<\/pre>\n<p><b>\uc0ac\uc6a9\ubc95<\/b><\/p>\n<p style=\"padding-left: 40px\"><span style=\"font-weight: 400\">\uc778\uc218 1: <em>\uc575\ucee4<\/em> \ucffc\ub9ac, \ubb38\uc790\uc5f4<\/span><span style=\"font-weight: 400\"><br \/>\n<\/span><span style=\"font-weight: 400\">\uc778\uc218 2: <em>\uc7ac\uadc0\uc801<\/em> \ucffc\ub9ac, \ubb38\uc790\uc5f4 <\/span><span style=\"font-weight: 400\">(\uc0ac\uc6a9 <\/span><i><span style=\"font-weight: 400\">$1(\uc0c1\ud0dc \ud45c\ud604\uc2dd)<\/span><\/i><span style=\"font-weight: 400\"> \uc774\uc804 \ubc18\ubcf5\uc758 \uacb0\uacfc\ub97c \ucc38\uc870\ud558\uae30 \uc704\ud574)<\/span><span style=\"font-weight: 400\"><br \/>\n<\/span><span style=\"font-weight: 400\">\uc778\uc218 3: \uad6c\uc131 <em>\uc635\uc158<\/em>\uac1d\uccb4<\/span><span style=\"font-weight: 400\"><br \/>\n<\/span><span style=\"font-weight: 400\"><br \/>\n<\/span><span style=\"font-weight: 400\">\ubaa8\ub450 <\/span><b>\ud544\uc218<\/b><span style=\"font-weight: 400\">\ub97c \uc804\ub2ec\ud560 \uc218 \uc788\uc9c0\ub9cc <\/span><i><span style=\"font-weight: 400\">\ube48 \uac1c\uccb4<\/span><\/i><span style=\"font-weight: 400\">\uc989., <\/span><i><span style=\"font-weight: 400\">{}<\/span><\/i><span style=\"font-weight: 400\"> \uad6c\uc131 \uc635\uc158\uc744 \uc0ac\uc6a9\ud558\uc9c0 \uc54a\ub294 \uacbd\uc6b0 \ub97c \uc785\ub825\ud569\ub2c8\ub2e4.<\/span><\/p>\n<p><span style=\"font-weight: 400\"><br \/>\n<\/span><b>\uad6c\uc131 \uc635\uc158<\/b><b><\/b><\/p>\n<p style=\"padding-left: 40px\"><b>\uc870\uae30 \uc885\ub8cc<\/b><\/p>\n<p style=\"padding-left: 40px\"><span style=\"font-weight: 400\"><em>levelLimit<\/em>(1 ~ N) - \uba48\ucd9c \uc218 \uc788\ub294 \ub808\ubca8\uc744 \uc9c0\uc815\ud569\ub2c8\ub2e4. \ub808\ubca8 \uce74\uc6b4\ud2b8\ub294 \ub2e4\uc74c\uc5d0\uc11c \uc2dc\uc791\ub429\ub2c8\ub2e4. <\/span><i><span style=\"font-weight: 400\">0<\/span><\/i><span style=\"font-weight: 400\"> \uc575\ucee4 \uacb0\uacfc\ub97c \ud655\uc778\ud569\ub2c8\ub2e4, <\/span><i><span style=\"font-weight: 400\">1<\/span><\/i><span style=\"font-weight: 400\"> \ub97c \uccab \ubc88\uc9f8 \ubc18\ubcf5\/\ub808\ubca8\uc5d0 \uc0ac\uc6a9\ud569\ub2c8\ub2e4, <\/span><i><span style=\"font-weight: 400\">2<\/span><\/i><span style=\"font-weight: 400\"> \ub450 \ubc88\uc9f8 \ub4f1<\/span><\/p>\n<p style=\"padding-left: 40px\"><b>\ub0b4\ubd80 \ucffc\ub9ac\uc5d0 \ub300\ud55c \uc778\uc218<\/b><\/p>\n<p style=\"padding-left: 40px\"><span style=\"font-weight: 400\"><em>anchorArgs<\/em> - \uc608\ub97c \ub4e4\uc5b4<\/span><i><span style=\"font-weight: 400\">{\"arg:1}<\/span><\/i><span style=\"font-weight: 400\"> \ub610\ub294 \uc704\uce58 \uc778\uc790(\uc608: <\/span><i><span style=\"font-weight: 400\">[1]<\/span><\/i><span style=\"font-weight: 400\"> \ub97c \uc0ac\uc6a9\ud558\uc5ec \uc575\ucee4 \ucffc\ub9ac\uc5d0 \uc0ac\uc6a9\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/span><\/p>\n<p style=\"padding-left: 40px\"><span style=\"font-weight: 400\"><em>recursiveArgs<\/em> - \uc704\uce58 \uc778\uc218\ub9cc \uac00\ub2a5\ud558\uba70 <\/span><i><span style=\"font-weight: 400\">0<\/span><\/i><span style=\"font-weight: 400\"> \uc778\ub371\uc2a4\ub294 \uc0c1\ud0dc \ud45c\ud604\uc2dd\uc744 \uc704\ud574 \uc608\uc57d\ud574\uc57c \ud569\ub2c8\ub2e4. \uc608\ub97c \ub4e4\uc5b4 <\/span><i><span style=\"font-weight: 400\">[0, 1] <\/span><\/i><span style=\"font-weight: 400\">- \ud56d\uc0c1 0\ubc88\uc9f8 \uc778\ub371\uc2a4(<\/span><i><span style=\"font-weight: 400\">$1<\/span><\/i><span style=\"font-weight: 400\"> \uc778\uc218)\uc5d0\uc11c <\/span><i><span style=\"font-weight: 400\">0<\/span><\/i><span style=\"font-weight: 400\">\ub97c \uc0ac\uc6a9\ud558\uc5ec \uc7ac\uadc0 \uc808\uc5d0\uc11c \uc0c1\ud0dc \ud45c\ud604\uc2dd\uc73c\ub85c \uc0ac\uc6a9\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/span><\/p>\n<p style=\"padding-left: 40px\"><b>\uc8fc\uae30 \uac10\uc9c0<\/b><\/p>\n<p style=\"padding-left: 40px\"><span style=\"font-weight: 400\"><em>\uc8fc\uae30 \ud544\ub4dc<\/em> - \ud544\ub4dc \uc774\ub984\uc758 \ubc30\uc5f4(\uc608:, <\/span><i><span style=\"font-weight: 400\">[\"_from\", \"_to\"]<\/span><\/i><\/p>\n<p style=\"padding-left: 40px\"><b>\uc124\uba85<\/b><\/p>\n<p style=\"padding-left: 40px\"><span style=\"font-weight: 400\"><em>\uc124\uba85<\/em> - \ub85c\uadf8\uc5d0\uc11c \ucffc\ub9ac \uacc4\ud68d \ud655\uc778(\uc138\ud2b8 <\/span><i><span style=\"font-weight: 400\">\ub85c\uadf8 <\/span><\/i><span style=\"font-weight: 400\">\uae30\ubcf8\uac12)<\/span><\/p>\n<p style=\"padding-left: 40px\"><b>\ub85c\uadf8<\/b><\/p>\n<p style=\"padding-left: 40px\"><span style=\"font-weight: 400\"><em>\ub85c\uadf8<\/em> - \uac1c\ubc1c \uc911 \ub85c\uae45\uc744 \ud558\uace0 \uc2f6\uc744 \ub54c \ub3c4\uc6c0\uc774 \ub418\ub294 \ub85c\uadf8 \ud45c\uc2dc<\/span><\/p>\n<p>&nbsp;<\/p>\n<h2><span style=\"font-weight: 400\">\uc0d8\ud50c \ucffc\ub9ac<\/span><\/h2>\n<p><span style=\"font-weight: 400\"><br \/>\n<\/span><b>1.<\/b><span style=\"font-weight: 400\"> <b>\uc22b\uc790 1\ubd80\ud130 N\uae4c\uc9c0 \uc138\uae30<\/b> - \uc7ac\uadc0\uc801 CTE\uc758 \uc791\ub3d9 \ubc29\uc2dd\uc744 \ubcf4\uc5ec\uc8fc\ub294 \uac00\uc7a5 \uac04\ub2e8\ud55c \ucffc\ub9ac \uc608\uc81c\uc785\ub2c8\ub2e4.<\/span><span style=\"font-weight: 400\"><br \/>\n<\/span><span style=\"font-weight: 400\">\u00a0 \u00a0\u00a0<\/span><span style=\"font-weight: 400\"><br \/>\n<\/span> <span style=\"font-weight: 400\">\uc7a0\uc2dc \uba48\ucdb0\uc11c N1QL\uc5d0\uc11c \uc774 \uae30\ub2a5\uc744 \uc0ac\uc6a9\ud558\uc9c0 \uc54a\uace0 \uc5b4\ub5bb\uac8c \uc774 \uc791\uc5c5\uc744 \uc218\ud589\ud560 \uc218 \uc788\ub294\uc9c0 \uc0dd\uac01\ud574 \ubcf4\uc138\uc694. <\/span><span style=\"font-weight: 400\">\uc720\ud2f8\ub9ac\ud2f0\ub97c \uac1c\ubc1c\ud588\uc2b5\ub2c8\ub2e4. \uac00\ub2a5\ud560\uae4c\uc694? (\uc544\ub2c8\uba74 \ubc29\uae08<\/span><b> N1QL \ud29c\ub9c1 \uc644\ub8cc!<\/b><span style=\"font-weight: 400\">)<br \/>\n<\/span><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-14571\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/06\/image_2023-06-23_125658889-1024x444.png\" alt=\"\" width=\"900\" height=\"390\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_125658889-1024x444.png 1024w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_125658889-300x130.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_125658889-768x333.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_125658889.png 1269w\" sizes=\"auto, (max-width: 900px) 100vw, 900px\" \/><\/p>\n<p><b>2. \uc9c1\uc6d0 \uc608\uc2dc<\/b> - \uc55e\uc11c \uc0b4\ud3b4\ubcf8 \uc9c1\uc6d0 \uceec\ub809\uc158\uc744 \ucc38\uc870\ud558\uc138\uc694.<\/p>\n<p style=\"padding-left: 40px\"><span style=\"font-weight: 400\">A. \uc9c1\uc6d0\uc758 \uc870\uc9c1 \uc218\uc900 \ucc3e\uae30<\/span><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-14572\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/06\/image_2023-06-23_125805870-1024x424.png\" alt=\"\" width=\"900\" height=\"373\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_125805870-1024x424.png 1024w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_125805870-300x124.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_125805870-768x318.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_125805870.png 1251w\" sizes=\"auto, (max-width: 900px) 100vw, 900px\" \/><\/p>\n<p style=\"padding-left: 40px\">B. <span style=\"font-weight: 400\">\uacc4\uce35 \uad6c\uc870\uc5d0 \ub300\ud55c \uc9c1\uc6d0\ubcc4 \ubcf4\uace0\uc11c<\/span><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-14573\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/06\/image_2023-06-23_125914592-1024x580.png\" alt=\"\" width=\"900\" height=\"510\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_125914592-1024x580.png 1024w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_125914592-300x170.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_125914592-768x435.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_125914592.png 1225w\" sizes=\"auto, (max-width: 900px) 100vw, 900px\" \/><\/p>\n<p><span style=\"font-weight: 400\">\uc575\ucee4 \ucffc\ub9ac: <\/span><\/p>\n<pre class=\"lang:default decode:true\">SELECT e1.*, 0 as hlevel\r\nFROM `employees` e1\r\nWHERE e1.manager_id=\" || to_str(e.employee_id)<\/pre>\n<p>\ucd94\uac00\ud560 \ub54c \ub108\ubb34 \uc7a5\ud669\ud574 \ubcf4\uc77c \uc218 \uc788\uc2b5\ub2c8\ub2e4. <em>\uc5b4\ub514<\/em> \uc220\uc5b4\ub97c \uc678\ubd80 \ucffc\ub9ac\uc5d0\uc11c \uac00\uc838\uc635\ub2c8\ub2e4.  W<span style=\"font-weight: 400\">\ub97c \uc0ac\uc6a9\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. <\/span><em>anchorArgs<\/em> \uc635\uc158<span style=\"font-weight: 400\"> \ub97c \uc0ac\uc6a9\ud558\uc5ec \uc774\ub97c \uc644\ud654\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4!<\/span><\/p>\n<h3><span style=\"font-weight: 400\">\uc778\uc218(\uc575\ucee4Args\/\uc7ac\uadc0Args)<\/span><\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-14574\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/06\/image_2023-06-23_130029549-1024x191.png\" alt=\"\" width=\"900\" height=\"168\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_130029549-1024x191.png 1024w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_130029549-300x56.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_130029549-768x143.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_130029549.png 1253w\" sizes=\"auto, (max-width: 900px) 100vw, 900px\" \/><\/p>\n<p style=\"padding-left: 40px\"><strong>\uc124\uba85<\/strong><\/p>\n<p style=\"padding-left: 40px\"><span style=\"font-weight: 400\">\uc81c\uacf5 <\/span><span style=\"font-weight: 400\">{\"explain\": true} - <\/span><span style=\"font-weight: 400\">\ub85c\uadf8 \ud544\ub4dc\uc5d0\uc11c \ucffc\ub9ac \uacc4\ud68d\uc744 \ud655\uc778\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.\u00a0<\/span><\/p>\n<p style=\"padding-left: 40px\"><strong>\uc870\uae30 \uc885\ub8cc<\/strong><\/p>\n<p style=\"padding-left: 40px\"><span style=\"font-weight: 400\">\uc124\uc815 <\/span><i><span style=\"font-weight: 400\">levelLimit <\/span><\/i><span style=\"font-weight: 400\">\uac19\uc740 <\/span><i><span style=\"font-weight: 400\">{\"levelLimit\":2}<\/span><\/i><span style=\"font-weight: 400\"> - 2\ub2e8\uacc4 \uc7ac\uadc0\ub9cc \uc6d0\ud558\ub294 \uacbd\uc6b0<\/span><\/p>\n<p>&nbsp;<\/p>\n<p style=\"padding-left: 40px\"><strong>\uc8fc\uae30 \uac10\uc9c0<\/strong><\/p>\n<p style=\"padding-left: 40px\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-14575\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/06\/image_2023-06-23_130205451-1024x334.png\" alt=\"\" width=\"900\" height=\"294\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_130205451-1024x334.png 1024w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_130205451-300x98.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_130205451-768x250.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_130205451.png 1271w\" sizes=\"auto, (max-width: 900px) 100vw, 900px\" \/><\/p>\n<p style=\"padding-left: 40px\"><b>\uc0ac\uc774\ud074 \uac10\uc9c0 \uae30\ub2a5 \uc5c6\uc74c <\/b><span style=\"font-weight: 400\">\uc9c1\uc6d0 \uc218\uc900 \uacc4\uce35\uc744 \ucc3e\uae30 \uc704\ud55c \ucffc\ub9ac\ub294 <\/span><b>\ubb34\ud55c \ub8e8\ud504 <\/b><i><span style=\"font-weight: 400\">\ud568\uc218 \ud0c0\uc784\uc544\uc6c3 \uc2dc \ucda9\ub3cc\uc774 \ubc1c\uc0dd\ud558\uc5ec CPU \ub9ac\uc18c\uc2a4\ub97c \ub0ad\ube44\ud569\ub2c8\ub2e4.<\/span><\/i><span style=\"font-weight: 400\"><br \/>\n<\/span><span style=\"font-weight: 400\"><br \/>\n<\/span><span style=\"font-weight: 400\">\uadf8\ub798\ud504 \ub370\uc774\ud130\ub85c \uc791\uc5c5\ud560 \ub54c \uc0ac\uc774\ud074\uc774 \uc874\uc7ac\ud560 \uac00\ub2a5\uc131\uc774 \ub192\ub2e4\ub294 \uc810\uc744 \uace0\ub824\ud558\uba74 <\/span><b>\uc801\uc808\ud55c \ud544\ub4dc\uc758 \uc8fc\uae30 \uac10\uc9c0\ub97c \uc124\uc815\ud558\ub294 \uac83\uc740 \ud568\uc218 \ud638\ucd9c\uc790\uc758 \ucc45\uc784\uc785\ub2c8\ub2e4.<\/b><\/p>\n<p style=\"padding-left: 40px\"><span style=\"font-weight: 400\">\uc5ec\uae30\uc5d0\uc11c <\/span><i><span style=\"font-weight: 400\">\"employee_id\"<\/span><\/i><span style=\"font-weight: 400\">, <\/span><i><span style=\"font-weight: 400\">\"manager_id\"<\/span><\/i><span style=\"font-weight: 400\">\u00a0 \uc30d\uc740 \uc8fc\uae30\uc801\uc73c\ub85c \uc885\ub8cc\ud558\uae30\uc5d0 \ucda9\ubd84\ud569\ub2c8\ub2e4.<\/span><\/p>\n<p style=\"padding-left: 40px\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-14576\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/06\/image_2023-06-23_130306815-1024x312.png\" alt=\"\" width=\"900\" height=\"274\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_130306815-1024x312.png 1024w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_130306815-300x92.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_130306815-768x234.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/image_2023-06-23_130306815.png 1259w\" sizes=\"auto, (max-width: 900px) 100vw, 900px\" \/><\/p>\n<p>\uc774 \uc5b4\ub824\uc6b4 \uc8fc\uc81c\uc5d0 \uad00\uc2ec\uc744 \uac00\uc838\uc8fc\uc154\uc11c \uac10\uc0ac\ub4dc\ub9ac\uba70, \uc7ac\uadc0 \ucffc\ub9ac \ubb38\uc81c\ub97c \ud574\uacb0\ud560 \uc218 \uc788\ub294 \ub354 \ub9ce\uc740 \uc635\uc158\uc774 \uacf5\uac1c\ub418\uae30\ub97c \ubc14\ub78d\ub2c8\ub2e4!<\/p>\n<h2><span style=\"font-weight: 400\">\ucc38\uc870<\/span><\/h2>\n<ul>\n<li style=\"list-style-type: none\">\n<ul>\n<li style=\"font-weight: 400\"><a href=\"https:\/\/www.baeldung.com\/cs\/convert-recursion-to-iteration\"><span style=\"font-weight: 400\">\uc7ac\uadc0 \ud568\uc218\ub97c \ubc18\ubcf5 \ud568\uc218\ub85c \ubcc0\ud658(Baeldung)<\/span><\/a><\/li>\n<li style=\"font-weight: 400\"><a href=\"https:\/\/docs.couchbase.com\/server\/current\/n1ql\/n1ql-language-reference\/index.html\"><span style=\"font-weight: 400\">SQL++ \uc5b8\uc5b4 \ucc38\uc870 \ubb38\uc11c<\/span><\/a><\/li>\n<li style=\"font-weight: 400\"><a href=\"https:\/\/www.mongodb.com\/docs\/manual\/reference\/operator\/aggregation\/graphLookup\/?_ga=2.234064094.1723037650.1675387315-1783168968.1675058199#-graphlookup--aggregation-\"><span style=\"font-weight: 400\">\ubabd\uace0DB \uadf8\ub798\ud504 \uc870\ud68c \ucc38\uc870<\/span><\/a><\/li>\n<li style=\"font-weight: 400\"><a href=\"https:\/\/docs.snowflake.com\/en\/user-guide\/queries-cte#recursive-ctes-and-hierarchical-data\"><span style=\"font-weight: 400\">\ub208\uc1a1\uc774 \uc7ac\uadc0\uc801 CTE \ub808\ud37c\ub7f0\uc2a4<\/span><\/a><\/li>\n<li style=\"font-weight: 400\"><a href=\"https:\/\/www.couchbase.com\/blog\/ko\/from-n1ql-to-javascript-and-back-part-1-introduction\/\"><span style=\"font-weight: 400\">\ube14\ub85c\uadf8 N1QL\uc5d0\uc11c \uc790\ubc14\uc2a4\ud06c\ub9bd\ud2b8\ub85c - 1\ubd80<\/span><\/a><\/li>\n<li style=\"font-weight: 400\"><a href=\"https:\/\/www.postgresql.org\/docs\/current\/queries-with.html\"><span style=\"font-weight: 400\">PostgreSQL \ucffc\ub9ac \ucc38\uc870, WITH \uc808<\/span><\/a><\/li>\n<li style=\"font-weight: 400\"><a href=\"https:\/\/docs.couchbase.com\/server\/current\/n1ql\/n1ql-intro\/queriesandresults.html#named-placeholders\"><span style=\"font-weight: 400\">SQL++ \ucffc\ub9ac \ubc0f \uacb0\uacfc \ubb38\uc11c<\/span><\/a><\/li>\n<li style=\"font-weight: 400\"><a href=\"https:\/\/docs.couchbase.com\/server\/current\/guides\/create-javascript-library.html\"><span style=\"font-weight: 400\">JavaScript \ub77c\uc774\ube0c\ub7ec\ub9ac \ub9cc\ub4e4\uae30 \ubb38\uc11c<\/span><\/a><\/li>\n<li style=\"font-weight: 400\"><a href=\"https:\/\/docs.couchbase.com\/server\/current\/guides\/create-user-defined-function.html\"><span style=\"font-weight: 400\">\uce74\uc6b0\uce58\ubca0\uc774\uc2a4\uc5d0\uc11c \uc0ac\uc6a9\uc790 \uc815\uc758 \ud568\uc218(UDF) \ub9cc\ub4e4\uae30<\/span><\/a><\/li>\n<\/ul>\n<\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>It is extremely likely that you have come across issues with hierarchical lookups or graph traversal in your application as a developer who handles real-world use cases. And, for obvious reasons, you prefer solving them at the database layer and [&hellip;]<\/p>","protected":false},"author":84423,"featured_media":14577,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[1816,1819,9327,1812],"tags":[9836,8911],"ppma_author":[9835],"class_list":["post-14562","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-couchbase-server","category-data-modeling","category-javascript","category-n1ql-query","tag-recursive-queries","tag-udf"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.0 (Yoast SEO v26.0) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Recursive Query Processing in SQL++ (N1QL) Function<\/title>\n<meta name=\"description\" content=\"Users can emulate recursive CTE using JavaScript UDFs with existing infrastructure. This Couchbase blog post demonstrates just how to do that and 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\/ko\/recursive-query-processing-in-sql-n1ql\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Recursive Query Processing in SQL++ (N1QL)\" \/>\n<meta property=\"og:description\" content=\"Users can emulate recursive CTE using JavaScript UDFs with existing infrastructure. This Couchbase blog post demonstrates just how to do that and more!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/ko\/recursive-query-processing-in-sql-n1ql\/\" \/>\n<meta property=\"og:site_name\" content=\"The Couchbase Blog\" \/>\n<meta property=\"article:published_time\" content=\"2023-06-23T20:15:52+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-03-01T17:01:33+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/06\/remy-penet-zaM9LhySx_0-unsplash-scaled.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"2560\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Gaurav Jayaraj - 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=\"Gaurav Jayaraj - Software Engineer\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/recursive-query-processing-in-sql-n1ql\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/recursive-query-processing-in-sql-n1ql\/\"},\"author\":{\"name\":\"Gaurav Jayaraj - Software Engineer\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/546cec92f77cbb0b09f9b973fd1c8d42\"},\"headline\":\"Recursive Query Processing in SQL++ (N1QL)\",\"datePublished\":\"2023-06-23T20:15:52+00:00\",\"dateModified\":\"2024-03-01T17:01:33+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/recursive-query-processing-in-sql-n1ql\/\"},\"wordCount\":1232,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/recursive-query-processing-in-sql-n1ql\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/remy-penet-zaM9LhySx_0-unsplash-scaled.jpg\",\"keywords\":[\"recursive queries\",\"User Defined Function (UDF)\"],\"articleSection\":[\"Couchbase Server\",\"Data Modeling\",\"JavaScript\",\"SQL++ \/ N1QL Query\"],\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/recursive-query-processing-in-sql-n1ql\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/recursive-query-processing-in-sql-n1ql\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/recursive-query-processing-in-sql-n1ql\/\",\"name\":\"Recursive Query Processing in SQL++ (N1QL) Function\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/recursive-query-processing-in-sql-n1ql\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/recursive-query-processing-in-sql-n1ql\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/remy-penet-zaM9LhySx_0-unsplash-scaled.jpg\",\"datePublished\":\"2023-06-23T20:15:52+00:00\",\"dateModified\":\"2024-03-01T17:01:33+00:00\",\"description\":\"Users can emulate recursive CTE using JavaScript UDFs with existing infrastructure. This Couchbase blog post demonstrates just how to do that and more!\",\"breadcrumb\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/recursive-query-processing-in-sql-n1ql\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/recursive-query-processing-in-sql-n1ql\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/recursive-query-processing-in-sql-n1ql\/#primaryimage\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/remy-penet-zaM9LhySx_0-unsplash-scaled.jpg\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/remy-penet-zaM9LhySx_0-unsplash-scaled.jpg\",\"width\":1920,\"height\":2560,\"caption\":\"Fibonacci design of staircase by Remy Penet on Unsplash\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/recursive-query-processing-in-sql-n1ql\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.couchbase.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Recursive Query Processing in SQL++ (N1QL)\"}]},{\"@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\":\"ko-KR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\",\"name\":\"The Couchbase Blog\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@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\/546cec92f77cbb0b09f9b973fd1c8d42\",\"name\":\"Gaurav Jayaraj - Software Engineer\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/a332e5d7f47865015367ca88af3e5891\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2025\/02\/unnamed-2.jpg\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2025\/02\/unnamed-2.jpg\",\"caption\":\"Gaurav Jayaraj - Software Engineer\"},\"description\":\"Gaurav Jayaraj is an intern in the Query team at Couchbase R&amp;D. Gaurav is pursuing his Bachelors in Computer Science from PES University, Bangalore.\",\"url\":\"https:\/\/www.couchbase.com\/blog\/ko\/author\/gauravjayaraj\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"SQL++\uc758 \uc7ac\uadc0 \ucffc\ub9ac \ucc98\ub9ac(N1QL) \ud568\uc218","description":"\uc0ac\uc6a9\uc790\ub294 \uae30\uc874 \uc778\ud504\ub77c\uc5d0\uc11c JavaScript UDF\ub97c \uc0ac\uc6a9\ud558\uc5ec \uc7ac\uadc0\uc801 CTE\ub97c \uc5d0\ubbac\ub808\uc774\uc158\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \uc774 \uce74\uc6b0\uce58\ubca0\uc774\uc2a4 \ube14\ub85c\uadf8 \uac8c\uc2dc\ubb3c\uc740 \uadf8 \ubc29\ubc95\uacfc \uadf8 \uc774\uc0c1\uc744 \ubcf4\uc5ec\uc90d\ub2c8\ub2e4!","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\/ko\/recursive-query-processing-in-sql-n1ql\/","og_locale":"ko_KR","og_type":"article","og_title":"Recursive Query Processing in SQL++ (N1QL)","og_description":"Users can emulate recursive CTE using JavaScript UDFs with existing infrastructure. This Couchbase blog post demonstrates just how to do that and more!","og_url":"https:\/\/www.couchbase.com\/blog\/ko\/recursive-query-processing-in-sql-n1ql\/","og_site_name":"The Couchbase Blog","article_published_time":"2023-06-23T20:15:52+00:00","article_modified_time":"2024-03-01T17:01:33+00:00","og_image":[{"width":1920,"height":2560,"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/06\/remy-penet-zaM9LhySx_0-unsplash-scaled.jpg","type":"image\/jpeg"}],"author":"Gaurav Jayaraj - Software Engineer","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Gaurav Jayaraj - Software Engineer","Est. reading time":"8\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.couchbase.com\/blog\/recursive-query-processing-in-sql-n1ql\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/recursive-query-processing-in-sql-n1ql\/"},"author":{"name":"Gaurav Jayaraj - Software Engineer","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/546cec92f77cbb0b09f9b973fd1c8d42"},"headline":"Recursive Query Processing in SQL++ (N1QL)","datePublished":"2023-06-23T20:15:52+00:00","dateModified":"2024-03-01T17:01:33+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/recursive-query-processing-in-sql-n1ql\/"},"wordCount":1232,"commentCount":0,"publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/recursive-query-processing-in-sql-n1ql\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/remy-penet-zaM9LhySx_0-unsplash-scaled.jpg","keywords":["recursive queries","User Defined Function (UDF)"],"articleSection":["Couchbase Server","Data Modeling","JavaScript","SQL++ \/ N1QL Query"],"inLanguage":"ko-KR","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/blog\/recursive-query-processing-in-sql-n1ql\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/recursive-query-processing-in-sql-n1ql\/","url":"https:\/\/www.couchbase.com\/blog\/recursive-query-processing-in-sql-n1ql\/","name":"SQL++\uc758 \uc7ac\uadc0 \ucffc\ub9ac \ucc98\ub9ac(N1QL) \ud568\uc218","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/recursive-query-processing-in-sql-n1ql\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/recursive-query-processing-in-sql-n1ql\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/remy-penet-zaM9LhySx_0-unsplash-scaled.jpg","datePublished":"2023-06-23T20:15:52+00:00","dateModified":"2024-03-01T17:01:33+00:00","description":"\uc0ac\uc6a9\uc790\ub294 \uae30\uc874 \uc778\ud504\ub77c\uc5d0\uc11c JavaScript UDF\ub97c \uc0ac\uc6a9\ud558\uc5ec \uc7ac\uadc0\uc801 CTE\ub97c \uc5d0\ubbac\ub808\uc774\uc158\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \uc774 \uce74\uc6b0\uce58\ubca0\uc774\uc2a4 \ube14\ub85c\uadf8 \uac8c\uc2dc\ubb3c\uc740 \uadf8 \ubc29\ubc95\uacfc \uadf8 \uc774\uc0c1\uc744 \ubcf4\uc5ec\uc90d\ub2c8\ub2e4!","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/recursive-query-processing-in-sql-n1ql\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/recursive-query-processing-in-sql-n1ql\/"]}]},{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/www.couchbase.com\/blog\/recursive-query-processing-in-sql-n1ql\/#primaryimage","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/remy-penet-zaM9LhySx_0-unsplash-scaled.jpg","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2023\/06\/remy-penet-zaM9LhySx_0-unsplash-scaled.jpg","width":1920,"height":2560,"caption":"Fibonacci design of staircase by Remy Penet on Unsplash"},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/blog\/recursive-query-processing-in-sql-n1ql\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Recursive Query Processing in SQL++ (N1QL)"}]},{"@type":"WebSite","@id":"https:\/\/www.couchbase.com\/blog\/#website","url":"https:\/\/www.couchbase.com\/blog\/","name":"\uce74\uc6b0\uce58\ubca0\uc774\uc2a4 \ube14\ub85c\uadf8","description":"NoSQL \ub370\uc774\ud130\ubca0\uc774\uc2a4, Couchbase","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":"ko-KR"},{"@type":"Organization","@id":"https:\/\/www.couchbase.com\/blog\/#organization","name":"\uce74\uc6b0\uce58\ubca0\uc774\uc2a4 \ube14\ub85c\uadf8","url":"https:\/\/www.couchbase.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"ko-KR","@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\/546cec92f77cbb0b09f9b973fd1c8d42","name":"\uac00\uc6b0\ub77c\ube0c \uc790\uc57c\ub77c\uc988 - \uc18c\ud504\ud2b8\uc6e8\uc5b4 \uc5d4\uc9c0\ub2c8\uc5b4","image":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/a332e5d7f47865015367ca88af3e5891","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2025\/02\/unnamed-2.jpg","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2025\/02\/unnamed-2.jpg","caption":"Gaurav Jayaraj - Software Engineer"},"description":"\uac00\uc6b0\ub77c\ube0c \uc790\uc57c\ub77c\uc988\ub294 \uce74\uc6b0\uce58\ubca0\uc774\uc2a4 R&amp;D\uc758 \ucffc\ub9ac \ud300\uc5d0\uc11c \uc778\ud134\uc73c\ub85c \uadfc\ubb34\ud558\uace0 \uc788\uc2b5\ub2c8\ub2e4. Gaurav\ub294 \ubc29\uac08\ub85c\ub974\uc758 PES \ub300\ud559\uc5d0\uc11c \ucef4\ud4e8\ud130 \uacf5\ud559 \ud559\uc0ac \ud559\uc704\ub97c \ucde8\ub4dd\ud588\uc2b5\ub2c8\ub2e4.","url":"https:\/\/www.couchbase.com\/blog\/ko\/author\/gauravjayaraj\/"}]}},"authors":[{"term_id":9835,"user_id":84423,"is_guest":0,"slug":"gauravjayaraj","display_name":"Gaurav Jayaraj - Software Engineer","avatar_url":{"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2025\/02\/unnamed-2.jpg","url2x":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2025\/02\/unnamed-2.jpg"},"author_category":"","last_name":"Jayaraj - Software Engineer","first_name":"Gaurav","job_title":"","user_url":"","description":"\uac00\uc6b0\ub77c\ube0c \uc790\uc57c\ub77c\uc988\ub294 \uce74\uc6b0\uce58\ubca0\uc774\uc2a4 R&amp;D\uc758 \ucffc\ub9ac \ud300\uc5d0\uc11c \uc778\ud134\uc73c\ub85c \uadfc\ubb34\ud558\uace0 \uc788\uc2b5\ub2c8\ub2e4. Gaurav\ub294 \ubc29\uac08\ub85c\ub974\uc758 PES \ub300\ud559\uc5d0\uc11c \ucef4\ud4e8\ud130 \uacf5\ud559 \ud559\uc0ac \ud559\uc704\ub97c \ucde8\ub4dd\ud588\uc2b5\ub2c8\ub2e4."}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/posts\/14562","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/users\/84423"}],"replies":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/comments?post=14562"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/posts\/14562\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/media\/14577"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/media?parent=14562"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/categories?post=14562"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/tags?post=14562"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/ppma_author?post=14562"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}