{"id":12874,"date":"2022-03-14T10:23:48","date_gmt":"2022-03-14T17:23:48","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/?p=12874"},"modified":"2025-06-13T19:26:33","modified_gmt":"2025-06-14T02:26:33","slug":"reuse-sql-queries-between-server-mobile-app-databases","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/ko\/reuse-sql-queries-between-server-mobile-app-databases\/","title":{"rendered":"\uc11c\ubc84 \ubc0f \ubaa8\ubc14\uc77c \uc571 \ub370\uc774\ud130\ubca0\uc774\uc2a4 \uac04 SQL \ucffc\ub9ac \uc7ac\uc0ac\uc6a9"},"content":{"rendered":"<p><span style=\"font-weight: 400;\">As we all know, code is expensive to maintain\u2014the more complex the code, the higher the cost of maintaining it. Therefore, since the beginning of time, software developers have worked very hard to achieve the goal of <\/span><b>code reusability<\/b><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Couchbase Mobile 3.0 introduced support for SQL++ queries. As a developer, the first thought that came to mind was sharing queries used in projects targeting both Couchbase Server and Couchbase Mobile applications.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Is this a good idea? Let\u2019s explore that question using sample data and a proof-of-concept mobile application.<\/span><\/p>\n<h4><span style=\"font-weight: 400;\">Sample data<\/span><\/h4>\n<p><span style=\"font-weight: 400;\">All the code in this article is available on <\/span><a href=\"https:\/\/github.com\/biozal\/cblite-swiftui-icecream-locations\"><span style=\"font-weight: 400;\">GitHub<\/span><\/a><span style=\"font-weight: 400;\">. See the <\/span><a href=\"https:\/\/github.com\/biozal\/cblite-swiftui-icecream-locations\/blob\/main\/README.md\"><i><span style=\"font-weight: 400;\">README<\/span><\/i><\/a> <span style=\"font-weight: 400;\">for information on how to get the projects set up on your computer.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The sample data comes from the <\/span><a href=\"https:\/\/www.openstreetmap.org\/#map=5\/38.007\/-95.844\"><span style=\"font-weight: 400;\">OpenStreetMap<\/span><\/a><span style=\"font-weight: 400;\"> project and is licensed under the <\/span><a href=\"https:\/\/wiki.osmfoundation.org\/wiki\/Terms_of_Use\"><span style=\"font-weight: 400;\">Open Data Commons Open Database License (ODbL)<\/span><\/a><span style=\"font-weight: 400;\"> by the OpenStreetMap Foundation.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The data set contains all the shops that sell ice cream in the United States. An example JSON document is listed below:<\/span><\/p>\n<pre class=\"\">{\r\n \"type\": \"Feature\",\r\n \"id\": \"node\/472242349\",\r\n \"properties\": {\r\n \"addrCity\": \"Austin\",\r\n \"addrHousenumber\": \"4477\",\r\n \"addrPostcode\": \"78745\",\r\n \"addrState\": \"TX\",\r\n \"addrStreet\": \"South Lamar Boulevard\",\r\n \"addrUnit\": \"#790\",\r\n \"amenity\": \"ice_cream\",\r\n \"cuisine\": \"ice_cream\",\r\n \"name\": \"Amy's Ice Creams\",\r\n \"phone\": \"+1-512-891-0573\",\r\n \"id\": \"node\/472242349\"\r\n},\r\n  \"geometry\": {\r\n   \"type\": \"Point\",\r\n   \"coordinates\": [\r\n    -97.7998856,\r\n    30.230688\r\n  ]\r\n }\r\n}<\/pre>\n<p><span style=\"font-weight: 400;\">As you can see, this is a versatile dataset for testing because it has properties embedded into the documents.<\/span><\/p>\n<h4><span style=\"font-weight: 400;\">Sample mobile application<\/span><\/h4>\n<p><span style=\"font-weight: 400;\">The <a href=\"https:\/\/github.com\/biozal\/cblite-swiftui-icecream-locations\">sample mobile application<\/a> was written in <\/span><a href=\"https:\/\/developer.apple.com\/documentation\/swiftui\/\"><span style=\"font-weight: 400;\">SwiftUI<\/span><\/a><span style=\"font-weight: 400;\"> with <\/span><a href=\"https:\/\/developer.apple.com\/documentation\/combine\"><span style=\"font-weight: 400;\">Combine<\/span><\/a><span style=\"font-weight: 400;\"> and is an iOS\/macOS application that displays all the various shops that sell ice cream in the United States. The application includes a <\/span><a href=\"https:\/\/docs.couchbase.com\/couchbase-lite\/current\/swift\/prebuilt-database.html\"><span style=\"font-weight: 400;\">pre-built database<\/span><\/a><span style=\"font-weight: 400;\"> with the same JSON documents already imported into it for convenience. This mobile application uses the latest version of the <\/span><a href=\"https:\/\/docs.couchbase.com\/couchbase-lite\/current\/swift\/quickstart.html\"><span style=\"font-weight: 400;\">Couchbase Lite SDK<\/span><\/a><span style=\"font-weight: 400;\">. You can open the project in XCode from the project file in the src folder to follow along.<\/span><\/p>\n<h4><span style=\"font-weight: 400;\">A simple query comparison<\/span><\/h4>\n<p><span style=\"font-weight: 400;\">To start our testing, we can write a simple query, for Couchbase Server, to show all the ice cream shop addresses and order them by the shop name:<\/span><\/p>\n<pre class=\"decode-attributes:false lang:default decode:true\">SELECT id, properties.addrCity, properties.addrHousenumber, properties.addrPostcode, \r\nproperties.addrStreet, properties.addrState, properties.name \r\nFROM icecream \r\nWHERE properties.addrCity &lt;&gt; \"\" \r\nAND type = \"Feature\" \r\nORDER BY properties.name<\/pre>\n<p><span style=\"font-weight: 400;\">This query has a filter that only returns documents where the property&#8217;s object <\/span><i><span style=\"font-weight: 400;\">addrCity <\/span><\/i><span style=\"font-weight: 400;\">field has a value and where the document <\/span><i><span style=\"font-weight: 400;\">type<\/span><\/i><span style=\"font-weight: 400;\"> is equal to <\/span><i><span style=\"font-weight: 400;\">Feature<\/span><\/i><span style=\"font-weight: 400;\">. If you wonder why we have the <\/span><i><span style=\"font-weight: 400;\">addrCity<\/span><\/i><span style=\"font-weight: 400;\"> filter, it\u2019s because of dirty data or documents without names or missing information in this dataset. Using a <\/span><i><span style=\"font-weight: 400;\">type<\/span><\/i><span style=\"font-weight: 400;\"> attribute is common in mobile applications to filter out different types of documents.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">We can use the <\/span><b>Query Editor<\/b><span style=\"font-weight: 400;\"> from the Couchbase Server<\/span> <a href=\"https:\/\/docs.couchbase.com\/server\/current\/manage\/manage-ui\/manage-ui.html\"><b>Web Console<\/b><\/a><span style=\"font-weight: 400;\"> to run this query. When I ran this on my personal Macbook Pro M1 Max, the result came back in 38.4ms. This query uses the <\/span><i><span style=\"font-weight: 400;\">adv_properties_addrCity_type<\/span><\/i><span style=\"font-weight: 400;\"> index, which you can see by clicking the <\/span><b>Index Advisor<\/b><span style=\"font-weight: 400;\"> button.<\/span><\/p>\n<h4><span style=\"font-weight: 400;\">Porting the query to Couchbase Lite<\/span><\/h4>\n<p><span style=\"font-weight: 400;\">Now let\u2019s look at this same query running on our mobile app. To view the mobile app, you can use XCode to open up the <\/span><i><span style=\"font-weight: 400;\">IceCreamLocator.xcodeproj<\/span><\/i><span style=\"font-weight: 400;\"> file located in the <\/span><i><span style=\"font-weight: 400;\">src <\/span><\/i><span style=\"font-weight: 400;\">folder. Once opened in Xcode, find the <\/span><a href=\"https:\/\/github.com\/biozal\/cblite-swiftui-icecream-locations\/blob\/main\/src\/Shared\/Data\/IceCreamLocationRepository.swift#L32\"><i><span style=\"font-weight: 400;\">IceCreamLocationRepository<\/span><\/i><\/a><span style=\"font-weight: 400;\"> swift file in the <\/span><i><span style=\"font-weight: 400;\">Shared\\Data<\/span><\/i><span style=\"font-weight: 400;\"> folder.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The <\/span><i><span style=\"font-weight: 400;\">init <\/span><\/i><span style=\"font-weight: 400;\">function turns on verbose logging for the database to inspect the query information. Using verbose logging, you can review what\u2019s going on within Couchbase Lite, including query performance.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Let\u2019s review the simple query from Couchbase Server and see how it works in Swift with the new SQL++ Query API. The function for the simple query is named <\/span><a href=\"https:\/\/github.com\/biozal\/cblite-swiftui-icecream-locations\/blob\/main\/src\/Shared\/Data\/IceCreamLocationRepository.swift#L101\"><i><span style=\"font-weight: 400;\">getListByTypeCityOrderName<\/span><\/i><\/a><span style=\"font-weight: 400;\">, and the code is displayed below:<\/span><\/p>\n<pre class=\"decode-attributes:false lang:default decode:true\">  func getListByTypeCityOrderName() -&gt; Void {\r\n      do {\r\n        if let query = try _db?.createQuery(\"SELECT id, \r\nproperties.addrCity, properties.addrHousenumber, properties.addrPostcode, properties.addrStreet, \r\nproperties.addrState, properties.name FROM _ WHERE properties.addrCity &lt;&gt; \\\"\\\" AND \r\ntype = \\\"Feature\\\" ORDER BY properties.name\") {\r\n            var results: [IceCreamLocation] = []\r\n            let explain = try query.explain()\r\n            print (\"**EXPLAIN** \\(explain)\")\r\n            for result in try query.execute() {\r\n                if let data = result.toJSON().data(using: .utf8){\r\n                   let location = try \r\nJSONDecoder().decode(IceCreamLocation.self, from: data)\r\n                   results.append(location)\r\n             }\r\n           }\r\n           self.iceCreamLocationList.send(results)\r\n           self.iceCreamLocationList.send(completion: .finished)\r\n         }\r\n     } catch {\r\n         print(\"**Error**: \\(error)\")\r\n         self.iceCreamLocationList.send(completion: .failure(DbError.unknown))\r\n     }\r\n}<\/pre>\n<p><span style=\"font-weight: 400;\">There are a few ways to make an SQL++ query in Swift. In this example, we use the database <\/span><a href=\"https:\/\/docs.couchbase.com\/couchbase-lite\/current\/swift\/query-n1ql-mobile.html\"><i><span style=\"font-weight: 400;\">createQuery<\/span><\/i><\/a> <span style=\"font-weight: 400;\">function to create the query. In Couchbase Lite, I\u2019m using the underscore character (_) as the database name before the <\/span><i><span style=\"font-weight: 400;\">FROM <\/span><\/i><span style=\"font-weight: 400;\">statement. Changing the database name is one of the expected changes to reuse SQL++ statements. Also, to escape the quotation marks in the <\/span><i><span style=\"font-weight: 400;\">WHERE <\/span><\/i><span style=\"font-weight: 400;\">clause, I had to add the Swift string escape character (<\/span><i><span style=\"font-weight: 400;\">\\<\/span><\/i><span style=\"font-weight: 400;\">) before each quotation mark.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">To test this query while running, you can open the <\/span><a href=\"https:\/\/github.com\/biozal\/cblite-swiftui-icecream-locations\/blob\/main\/src\/Shared\/ViewModels\/IceCreamListViewModel.swift#L24\"><i><span style=\"font-weight: 400;\">IceCreamListViewModel<\/span><\/i><\/a> <span style=\"font-weight: 400;\">file found in the <\/span><i><span style=\"font-weight: 400;\">ViewModels <\/span><\/i><span style=\"font-weight: 400;\">folder. Locate the <\/span><i><span style=\"font-weight: 400;\">init <\/span><\/i><span style=\"font-weight: 400;\">function and uncomment out the first example line located at the bottom of the function that calls the <\/span><i><span style=\"font-weight: 400;\">getListByTypeCityOrderName<\/span><\/i><span style=\"font-weight: 400;\"> function from the <\/span><i><span style=\"font-weight: 400;\">_repository <\/span><\/i><span style=\"font-weight: 400;\">variable:<\/span><\/p>\n<pre class=\"\"> \/\/first example\r\n_repository.getListByTypeCityOrderName()<\/pre>\n<p><span style=\"font-weight: 400;\">Now you can use Xcode to run the application on an iOS Simulator or a macOS app. Next, open the <\/span><b>Debug Console <\/b><span style=\"font-weight: 400;\">in Xcode by clicking the <\/span><b>Show Debugging <\/b><span style=\"font-weight: 400;\">icon in the lower right corner of the Xcode editor, as highlighted below.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12888\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2022\/03\/properties.png\" alt=\"\" width=\"858\" height=\"396\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/03\/properties.png 858w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/03\/properties-300x138.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/03\/properties-768x354.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/03\/properties-20x9.png 20w\" sizes=\"auto, (max-width: 858px) 100vw, 858px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Verbose logging will display a massive amount of logging information. To help find the correct information in the logs, use the filter box below the console. For example, enter the text \u201c<\/span><i><span style=\"font-weight: 400;\">Query Info<\/span><\/i><span style=\"font-weight: 400;\">\u201d and then hit the enter key on your keyboard to see information about the query. The debug console will filter the data that Couchbase Lite returns.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Inspecting the logs will show you the <\/span><i><span style=\"font-weight: 400;\">Query Info<\/span><\/i><span style=\"font-weight: 400;\"> log entry and the number of documents found by the query, how many bytes and how long the query took. Remember, the numbers you are looking at are from a simulator, not an actual device. For performance tuning of mobile apps, you should use tools from Apple with a real device.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The speed at which this query ran is impressive. Even more impressive, there haven\u2019t been any indexes created yet, so this query runs without an index and does a table scan which means it has to look through the database at each document to see if it matches the requirements of the query. Couchbase Lite doesn\u2019t require indexes and will do table scans if needed, whereas Couchbase Server does require indexes because table scans can kill the performance of the entire cluster.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">In several cases adding indexes can significantly improve the performance of your queries, so let\u2019s stop running the application and add the proper index and recheck performance.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Open the <\/span><i><span style=\"font-weight: 400;\">IceCreamLocationRepository<\/span><\/i><span style=\"font-weight: 400;\"> and locate the <\/span><a href=\"https:\/\/github.com\/biozal\/cblite-swiftui-icecream-locations\/blob\/main\/src\/Shared\/Data\/IceCreamLocationRepository.swift#L84\"><i><span style=\"font-weight: 400;\">createIceCreamIndexes<\/span><\/i><\/a> <span style=\"font-weight: 400;\">function. Uncomment the first block of code for creating the first query index:<\/span><\/p>\n<pre class=\"lang:default decode:true\">   let simpleIndex = ValueIndexConfiguration([\"properties.name\", \"properties.addrCity\", \"type\"])\r\n   try _db?.createIndex(simpleIndex, name: \"idx_location_type_city_name\")<\/pre>\n<p><span style=\"font-weight: 400;\">How do we test to see if the query used the index we created? In the <\/span><i><span style=\"font-weight: 400;\">getListByTypeCityOrderName<\/span><\/i><span style=\"font-weight: 400;\"> function, you will see two lines that prints results from the explain function to the console:<\/span><\/p>\n<pre class=\"\">let explain = try query.explain()\r\nprint (\"**EXPLAIN** \\(explain)\")<\/pre>\n<p><span style=\"font-weight: 400;\">The query <\/span><a href=\"https:\/\/docs.couchbase.com\/couchbase-lite\/current\/swift\/troubleshooting-queries.html#using\"><span style=\"font-weight: 400;\">explain<\/span><\/a><span style=\"font-weight: 400;\"> function will run the equivalent of the SQLite <\/span><i><span style=\"font-weight: 400;\">EXPLAIN QUERY PLAN<\/span><\/i><span style=\"font-weight: 400;\"> command and store the results in a string you send to the console using the print function. You can filter for <\/span><i><span style=\"font-weight: 400;\">SCAN TABLE <\/span><\/i><span style=\"font-weight: 400;\">in your debug console to find the results. When reviewing the results, make sure you remove your previous filter from the console window. Now rerun the application and look through the logs to check the performance change.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12889\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2022\/03\/scantable.png\" alt=\"\" width=\"854\" height=\"485\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/03\/scantable.png 854w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/03\/scantable-300x170.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/03\/scantable-768x436.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/03\/scantable-20x11.png 20w\" sizes=\"auto, (max-width: 854px) 100vw, 854px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">You should see the <\/span><i><span style=\"font-weight: 400;\">USING INDEX <\/span><\/i><span style=\"font-weight: 400;\">with the created index name, which tells you that the query uses the proper index. Note that while indexes can help queries, they can also slow down insert and updates to documents. You can find more information about indexing in the Couchbase Lite <\/span><a href=\"https:\/\/docs.couchbase.com\/couchbase-lite\/current\/swift\/indexing.html\"><span style=\"font-weight: 400;\">documentation<\/span><\/a><span style=\"font-weight: 400;\">.<\/span><\/p>\n<h4><span style=\"font-weight: 400;\">Another query comparison<\/span><\/h4>\n<p><span style=\"font-weight: 400;\">In our second comparison, we filter out results only to show ice cream shops in the State of Georgia, ordered by City and State:<\/span><\/p>\n<pre class=\"\">SELECT id, properties.addrCity, properties.addHousenumber, properties.addrPostcode, \r\nproperties.addrStreet, properties.addrState, properties.name \r\nFROM icecream \r\nWHERE\r\nproperties.addrCity IS NOT NULL \r\nAND properties.addrState = 'GA'\r\nAND type = \"Feature\" \r\nORDER BY properties.name<\/pre>\n<p><span style=\"font-weight: 400;\">This query returns 15 documents and uses a different query since we use the <\/span><i><span style=\"font-weight: 400;\">properties.addrState <\/span><\/i><span style=\"font-weight: 400;\">and <\/span><i><span style=\"font-weight: 400;\">properties.addrCity<\/span><\/i><span style=\"font-weight: 400;\"> attributes in our <\/span><i><span style=\"font-weight: 400;\">WHERE <\/span><\/i><span style=\"font-weight: 400;\">clause.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Note that we switched out the way we check the <\/span><i><span style=\"font-weight: 400;\">properties.addrCity<\/span><\/i><span style=\"font-weight: 400;\"> attribute and use the <\/span><i><span style=\"font-weight: 400;\">IS NOT NULL<\/span><\/i><span style=\"font-weight: 400;\"> statement now. This shows the flexibility of the SQL++ language and how developers can use different syntax to produce the same results.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12890\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2022\/03\/selectID.png\" alt=\"\" width=\"1600\" height=\"699\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/03\/selectID.png 1600w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/03\/selectID-300x131.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/03\/selectID-1024x447.png 1024w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/03\/selectID-768x336.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/03\/selectID-1536x671.png 1536w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/03\/selectID-20x9.png 20w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/03\/selectID-1320x577.png 1320w\" sizes=\"auto, (max-width: 1600px) 100vw, 1600px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Now, let\u2019s go back to our mobile app to look at any differences. The function for our second query is named <\/span><a href=\"https:\/\/github.com\/biozal\/cblite-swiftui-icecream-locations\/blob\/main\/src\/Shared\/Data\/IceCreamLocationRepository.swift#L122\"><i><span style=\"font-weight: 400;\">getListByStateGeorgia<\/span><\/i><\/a><span style=\"font-weight: 400;\">, and the code is displayed below:<\/span><\/p>\n<pre class=\"decode-attributes:false lang:default decode:true\">    func getListByStateGeorgia() -&gt; Void {\r\n        do {\r\n           if let query = try _db?.createQuery(\"SELECT id, properties.addrCity, \r\nproperties.addrHousenumber, properties.addrPostcode, properties.addrStreet, \r\nproperties.addrState, properties.name FROM _ WHERE properties.addrCity NOT NULL AND \r\nproperties.addrState = \\\"GA\\\" AND type=\\\"Feature\\\" ORDER BY properties.name\") {\r\n               var results: [IceCreamLocation] = []\r\n               let explain = try query.explain()\r\n               print (\"**EXPLAIN** \\(explain)\")\r\n               for result in try query.execute() {\r\n                   if let data = result.toJSON().data(using: .utf8){\r\n                      let location = try \r\nJSONDecoder().decode(IceCreamLocation.self, from: data)\r\n                      results.append(location)\r\n                 }\r\n              }\r\n              self.iceCreamLocationList.send(results)\r\n              self.iceCreamLocationList.send(completion: .finished)\r\n          }\r\n        } catch {\r\n            print(\"**Error**: \\(error)\")\r\n            self.iceCreamLocationList.send(completion: .failure(DbError.unknown))\r\n     }\r\n   }<\/pre>\n<p><span style=\"font-weight: 400;\">To test this new query, you can open the <\/span><i><span style=\"font-weight: 400;\">IceCreamListViewModel<\/span><\/i><span style=\"font-weight: 400;\">. Locate the <\/span><a href=\"https:\/\/github.com\/biozal\/cblite-swiftui-icecream-locations\/blob\/main\/src\/Shared\/ViewModels\/IceCreamListViewModel.swift#L21\"><i><span style=\"font-weight: 400;\">init<\/span><\/i><\/a> <span style=\"font-weight: 400;\">function and comment out the first example line located at the bottom of the function that calls the <\/span><i><span style=\"font-weight: 400;\">getListByTypeCityOrderName <\/span><\/i><span style=\"font-weight: 400;\">function from the <\/span><i><span style=\"font-weight: 400;\">_repository<\/span><\/i><span style=\"font-weight: 400;\"> variable and uncomment out the line that calls our new function:<\/span><\/p>\n<pre class=\"\">\/\/first example\r\n\/\/_repository.getListByTypeCityOrderName()\r\n\r\n\/\/second example\r\n_repository.getListByStateGeorgia()<\/pre>\n<p><span style=\"font-weight: 400;\">You can debug the app using Xcode and check the debug area. It shows the same 15 documents that were returned by the query ran on Couchbase Server, but we are back to doing a table scan which isn\u2019t the behavior we want\u2014we changed the query, but we didn\u2019t create any new indexes yet.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12891\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2022\/03\/scantableusetemp.png\" alt=\"\" width=\"856\" height=\"420\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/03\/scantableusetemp.png 856w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/03\/scantableusetemp-300x147.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/03\/scantableusetemp-768x377.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/03\/scantableusetemp-20x10.png 20w\" sizes=\"auto, (max-width: 856px) 100vw, 856px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">To fix this, we can go back to the <\/span><a href=\"https:\/\/github.com\/biozal\/cblite-swiftui-icecream-locations\/blob\/main\/src\/Shared\/Data\/IceCreamLocationRepository.swift\"><i><span style=\"font-weight: 400;\">IceCreamLocationRepository<\/span><\/i><\/a> <span style=\"font-weight: 400;\">and locate the <\/span><a href=\"https:\/\/github.com\/biozal\/cblite-swiftui-icecream-locations\/blob\/main\/src\/Shared\/Data\/IceCreamLocationRepository.swift#L86\"><i><span style=\"font-weight: 400;\">createIceCreamIndexes<\/span><\/i><\/a> <span style=\"font-weight: 400;\">function. Uncomment the second block of code for creating the second query index:<\/span><\/p>\n<pre class=\"\">        let secondIndex = \r\nValueIndexConfiguration([\"properties.name\",\"properties.addrCity\", \"type\", \"properties.addrState\"])\r\n        try _db?.createIndex(secondIndex, name: \"idx_location_type_city_state_name\")<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12892\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2022\/03\/scantablelocationtype.png\" alt=\"\" width=\"860\" height=\"426\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/03\/scantablelocationtype.png 860w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/03\/scantablelocationtype-300x149.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/03\/scantablelocationtype-768x380.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/03\/scantablelocationtype-20x10.png 20w\" sizes=\"auto, (max-width: 860px) 100vw, 860px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">We found that we could reuse the code in these two more simple queries, but we had to add the indexes to avoid table scans.<\/span><\/p>\n<h4><span style=\"font-weight: 400;\">Catches with reusing queries<\/span><\/h4>\n<p><span style=\"font-weight: 400;\">Couchbase Server and Couchbase Mobile don\u2019t use the same storage or query engine. Therefore, you might run into Couchbase Server queries that need slight modifications to be optimized for Couchbase Mobile.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">For more information on Couchbase Server, check out the documentation on the <\/span><a href=\"https:\/\/docs.couchbase.com\/server\/current\/n1ql\/n1ql-language-reference\/cost-based-optimizer.html\"><span style=\"font-weight: 400;\">Cost-Based Optimizer<\/span><\/a><span style=\"font-weight: 400;\"> that the query engine uses. The Couchbase Developer portal also has a good article on improving <\/span><a href=\"https:\/\/developer.couchbase.com\/tutorial-tuning-tips-and-advice\"><span style=\"font-weight: 400;\">query performance<\/span><\/a><span style=\"font-weight: 400;\"> on Couchbase Server that can explain why some queries are written in a specific way.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">I recommend reading the Couchbase Mobile documentation on troubleshooting <\/span><a href=\"https:\/\/docs.couchbase.com\/couchbase-lite\/current\/swift\/troubleshooting-queries.html\"><span style=\"font-weight: 400;\">queries<\/span><\/a><span style=\"font-weight: 400;\"> as it has helped me write optimized queries and further explains the SQLite query plan output.<\/span><\/p>\n<h4><span style=\"font-weight: 400;\">Summary<\/span><\/h4>\n<p><span style=\"font-weight: 400;\">As shown in our code examples with the Couchbase Mobile 3.0 release, it is possible to reuse SQL++ code between Server and Mobile. However, you may need to modify queries and indexes for optimal performance. Given this, I highly recommend reading through the excellent documentation on <\/span><a href=\"https:\/\/docs.couchbase.com\/couchbase-lite\/current\/swift\/query-n1ql-mobile-server-diffs.html\"><span style=\"font-weight: 400;\">SQL++ for Mobile &#8211; Differences from SQL++ for Server<\/span><\/a><span style=\"font-weight: 400;\"> and <\/span><a href=\"https:\/\/docs.couchbase.com\/couchbase-lite\/current\/swift\/query-n1ql-mobile.html\"><span style=\"font-weight: 400;\">SQL++ Query Strings<\/span><\/a><span style=\"font-weight: 400;\">. It has valuable information on changes you might need to make to your queries to use them in your mobile applications.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Here are some of the primary resources referenced throughout the post:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><a href=\"https:\/\/github.com\/biozal\/cblite-swiftui-icecream-locations\"><span style=\"font-weight: 400;\">Code samples from GitHub<\/span><\/a><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><a href=\"https:\/\/www.openstreetmap.org\/#map=5\/38.007\/-95.844\"><span style=\"font-weight: 400;\">OpenStreetMap project<\/span><\/a><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><a href=\"https:\/\/docs.couchbase.com\/couchbase-lite\/current\/swift\/prebuilt-database.html\"><span style=\"font-weight: 400;\">Couchbase Mobile &#8211; Prebuilt database docs<\/span><\/a><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><a href=\"https:\/\/docs.couchbase.com\/couchbase-lite\/current\/swift\/quickstart.html\"><span style=\"font-weight: 400;\">Couchbase Lite on Swift &#8211; Quickstart docs<\/span><\/a><span style=\"font-weight: 400;\">\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><a href=\"https:\/\/docs.couchbase.com\/couchbase-lite\/current\/swift\/indexing.html\"><span style=\"font-weight: 400;\">Couchbase Lite &#8211; Indexing docs<\/span><\/a><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><a href=\"https:\/\/docs.couchbase.com\/server\/current\/n1ql\/n1ql-language-reference\/cost-based-optimizer.html\"><span style=\"font-weight: 400;\">Couchbase Server &#8211; Cost-based Optimizer docs<\/span><\/a><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><a href=\"https:\/\/developer.couchbase.com\/tutorial-tuning-tips-and-advice\"><span style=\"font-weight: 400;\">Couchbase Server &#8211; Tuning Tips and Advice<\/span><\/a><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><a href=\"https:\/\/docs.couchbase.com\/couchbase-lite\/current\/swift\/troubleshooting-queries.html\"><span style=\"font-weight: 400;\">Couchbase Mobile &#8211; Troubleshooting Queries<\/span><\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As we all know, code is expensive to maintain\u2014the more complex the code, the higher the cost of maintaining it. Therefore, since the beginning of time, software developers have worked very hard to achieve the goal of code reusability. Couchbase [&hellip;]<\/p>\n","protected":false},"author":77540,"featured_media":12893,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[1814,1810,1816,1812],"tags":[9527],"ppma_author":[9539],"class_list":["post-12874","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-application-design","category-couchbase-mobile","category-couchbase-server","category-n1ql-query","tag-mobile-3-0"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.3 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Reuse SQL Queries between Server &amp; Mobile App Databases - The Couchbase Blog<\/title>\n<meta name=\"description\" content=\"Couchbase Mobile 3.0 introduced support for SQL++ queries, learn how to reuse SQL queries between Server and Mobile App Databases.\" \/>\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\/reuse-sql-queries-between-server-mobile-app-databases\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Reuse SQL Queries between Server &amp; Mobile App Databases\" \/>\n<meta property=\"og:description\" content=\"Couchbase Mobile 3.0 introduced support for SQL++ queries, learn how to reuse SQL queries between Server and Mobile App Databases.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/ko\/reuse-sql-queries-between-server-mobile-app-databases\/\" \/>\n<meta property=\"og:site_name\" content=\"The Couchbase Blog\" \/>\n<meta property=\"article:published_time\" content=\"2022-03-14T17:23:48+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-14T02:26:33+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/03\/shutterstock_1013448550-scaled.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"2560\" \/>\n\t<meta property=\"og:image:height\" content=\"1440\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Aaron LaBeau - Principal Software Engineer\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@biozal\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Aaron LaBeau - Principal Software Engineer\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/reuse-sql-queries-between-server-mobile-app-databases\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/reuse-sql-queries-between-server-mobile-app-databases\\\/\"},\"author\":{\"name\":\"Aaron LaBeau - Principal Software Engineer\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/person\\\/8a68fa58a5fc5d8bf29577e7dc003a54\"},\"headline\":\"Reuse SQL Queries between Server &#038; Mobile App Databases\",\"datePublished\":\"2022-03-14T17:23:48+00:00\",\"dateModified\":\"2025-06-14T02:26:33+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/reuse-sql-queries-between-server-mobile-app-databases\\\/\"},\"wordCount\":1636,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/reuse-sql-queries-between-server-mobile-app-databases\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/1\\\/2022\\\/03\\\/shutterstock_1013448550-scaled.jpg\",\"keywords\":[\"mobile 3.0\"],\"articleSection\":[\"Application Design\",\"Couchbase Mobile\",\"Couchbase Server\",\"SQL++ \\\/ N1QL Query\"],\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/reuse-sql-queries-between-server-mobile-app-databases\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/reuse-sql-queries-between-server-mobile-app-databases\\\/\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/reuse-sql-queries-between-server-mobile-app-databases\\\/\",\"name\":\"Reuse SQL Queries between Server & Mobile App Databases - The Couchbase Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/reuse-sql-queries-between-server-mobile-app-databases\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/reuse-sql-queries-between-server-mobile-app-databases\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/1\\\/2022\\\/03\\\/shutterstock_1013448550-scaled.jpg\",\"datePublished\":\"2022-03-14T17:23:48+00:00\",\"dateModified\":\"2025-06-14T02:26:33+00:00\",\"description\":\"Couchbase Mobile 3.0 introduced support for SQL++ queries, learn how to reuse SQL queries between Server and Mobile App Databases.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/reuse-sql-queries-between-server-mobile-app-databases\\\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/reuse-sql-queries-between-server-mobile-app-databases\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/reuse-sql-queries-between-server-mobile-app-databases\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/1\\\/2022\\\/03\\\/shutterstock_1013448550-scaled.jpg\",\"contentUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/1\\\/2022\\\/03\\\/shutterstock_1013448550-scaled.jpg\",\"width\":2560,\"height\":1440},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/reuse-sql-queries-between-server-mobile-app-databases\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Reuse SQL Queries between Server &#038; Mobile App Databases\"}]},{\"@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\\\/8a68fa58a5fc5d8bf29577e7dc003a54\",\"name\":\"Aaron LaBeau - Principal Software Engineer\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/1\\\/2024\\\/09\\\/aaron-couchbase.jpg343f246f1f6971ad0851b3d3b558afbb\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/1\\\/2024\\\/09\\\/aaron-couchbase.jpg\",\"contentUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/1\\\/2024\\\/09\\\/aaron-couchbase.jpg\",\"caption\":\"Aaron LaBeau - Principal Software Engineer\"},\"description\":\"Aaron LaBeau is a Principal Software Engineer on the Developer Experience and Ecosystem team. He has over 29 years with substantial development experience in Objective-C, Swift, Kotlin, Java, C#, Javascript, and Typescript. You can find his GitHub profile at https:\\\/\\\/www.github.com\\\/biozal\\\/.\",\"sameAs\":[\"https:\\\/\\\/www.couchbase.com\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/aaron-labeau-b444747\\\/\",\"https:\\\/\\\/x.com\\\/biozal\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCXgF-JqwBRGSawXajr6plGg\"],\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/ko\\\/author\\\/biozal\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"\uc11c\ubc84\uc640 \ubaa8\ubc14\uc77c \uc571 \ub370\uc774\ud130\ubca0\uc774\uc2a4 \uac04\uc5d0 SQL \ucffc\ub9ac \uc7ac\uc0ac\uc6a9 - Couchbase \ube14\ub85c\uadf8","description":"\uce74\uc6b0\uce58\ubca0\uc774\uc2a4 \ubaa8\ubc14\uc77c 3.0\uc740 SQL++ \ucffc\ub9ac\ub97c \uc9c0\uc6d0\ud558\uba70, \uc11c\ubc84\uc640 \ubaa8\ubc14\uc77c \uc571 \ub370\uc774\ud130\ubca0\uc774\uc2a4 \uac04\uc5d0 SQL \ucffc\ub9ac\ub97c \uc7ac\uc0ac\uc6a9\ud558\ub294 \ubc29\ubc95\uc744 \uc54c\uc544\ubd05\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\/reuse-sql-queries-between-server-mobile-app-databases\/","og_locale":"ko_KR","og_type":"article","og_title":"Reuse SQL Queries between Server & Mobile App Databases","og_description":"Couchbase Mobile 3.0 introduced support for SQL++ queries, learn how to reuse SQL queries between Server and Mobile App Databases.","og_url":"https:\/\/www.couchbase.com\/blog\/ko\/reuse-sql-queries-between-server-mobile-app-databases\/","og_site_name":"The Couchbase Blog","article_published_time":"2022-03-14T17:23:48+00:00","article_modified_time":"2025-06-14T02:26:33+00:00","og_image":[{"width":2560,"height":1440,"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/03\/shutterstock_1013448550-scaled.jpg","type":"image\/jpeg"}],"author":"Aaron LaBeau - Principal Software Engineer","twitter_card":"summary_large_image","twitter_creator":"@biozal","twitter_misc":{"Written by":"Aaron LaBeau - Principal Software Engineer","Est. reading time":"10\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.couchbase.com\/blog\/reuse-sql-queries-between-server-mobile-app-databases\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/reuse-sql-queries-between-server-mobile-app-databases\/"},"author":{"name":"Aaron LaBeau - Principal Software Engineer","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/8a68fa58a5fc5d8bf29577e7dc003a54"},"headline":"Reuse SQL Queries between Server &#038; Mobile App Databases","datePublished":"2022-03-14T17:23:48+00:00","dateModified":"2025-06-14T02:26:33+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/reuse-sql-queries-between-server-mobile-app-databases\/"},"wordCount":1636,"commentCount":0,"publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/reuse-sql-queries-between-server-mobile-app-databases\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/03\/shutterstock_1013448550-scaled.jpg","keywords":["mobile 3.0"],"articleSection":["Application Design","Couchbase Mobile","Couchbase Server","SQL++ \/ N1QL Query"],"inLanguage":"ko-KR","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/blog\/reuse-sql-queries-between-server-mobile-app-databases\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/reuse-sql-queries-between-server-mobile-app-databases\/","url":"https:\/\/www.couchbase.com\/blog\/reuse-sql-queries-between-server-mobile-app-databases\/","name":"\uc11c\ubc84\uc640 \ubaa8\ubc14\uc77c \uc571 \ub370\uc774\ud130\ubca0\uc774\uc2a4 \uac04\uc5d0 SQL \ucffc\ub9ac \uc7ac\uc0ac\uc6a9 - Couchbase \ube14\ub85c\uadf8","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/reuse-sql-queries-between-server-mobile-app-databases\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/reuse-sql-queries-between-server-mobile-app-databases\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/03\/shutterstock_1013448550-scaled.jpg","datePublished":"2022-03-14T17:23:48+00:00","dateModified":"2025-06-14T02:26:33+00:00","description":"\uce74\uc6b0\uce58\ubca0\uc774\uc2a4 \ubaa8\ubc14\uc77c 3.0\uc740 SQL++ \ucffc\ub9ac\ub97c \uc9c0\uc6d0\ud558\uba70, \uc11c\ubc84\uc640 \ubaa8\ubc14\uc77c \uc571 \ub370\uc774\ud130\ubca0\uc774\uc2a4 \uac04\uc5d0 SQL \ucffc\ub9ac\ub97c \uc7ac\uc0ac\uc6a9\ud558\ub294 \ubc29\ubc95\uc744 \uc54c\uc544\ubd05\ub2c8\ub2e4.","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/reuse-sql-queries-between-server-mobile-app-databases\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/reuse-sql-queries-between-server-mobile-app-databases\/"]}]},{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/www.couchbase.com\/blog\/reuse-sql-queries-between-server-mobile-app-databases\/#primaryimage","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/03\/shutterstock_1013448550-scaled.jpg","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/03\/shutterstock_1013448550-scaled.jpg","width":2560,"height":1440},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/blog\/reuse-sql-queries-between-server-mobile-app-databases\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Reuse SQL Queries between Server &#038; Mobile App Databases"}]},{"@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\/8a68fa58a5fc5d8bf29577e7dc003a54","name":"Aaron LaBeau - \uc218\uc11d \uc18c\ud504\ud2b8\uc6e8\uc5b4 \uc5d4\uc9c0\ub2c8\uc5b4","image":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2024\/09\/aaron-couchbase.jpg343f246f1f6971ad0851b3d3b558afbb","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2024\/09\/aaron-couchbase.jpg","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2024\/09\/aaron-couchbase.jpg","caption":"Aaron LaBeau - Principal Software Engineer"},"description":"Aaron LaBeau\ub294 \uac1c\ubc1c\uc790 \uacbd\ud5d8 \ubc0f \uc5d0\ucf54\uc2dc\uc2a4\ud15c \ud300\uc758 \uc218\uc11d \uc18c\ud504\ud2b8\uc6e8\uc5b4 \uc5d4\uc9c0\ub2c8\uc5b4\uc785\ub2c8\ub2e4. \uadf8\ub294 29\ub144 \uc774\uc0c1 Objective-C, Swift, Kotlin, Java, C#, Javascript \ubc0f Typescript \ubd84\uc57c\uc5d0\uc11c \uc0c1\ub2f9\ud55c \uac1c\ubc1c \uacbd\ud5d8\uc744 \uc313\uc558\uc2b5\ub2c8\ub2e4. \uadf8\uc758 GitHub \ud504\ub85c\ud544\uc740 https:\/\/www.github.com\/biozal\/ \uc5d0\uc11c \ud655\uc778\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.","sameAs":["https:\/\/www.couchbase.com","https:\/\/www.linkedin.com\/in\/aaron-labeau-b444747\/","https:\/\/x.com\/biozal","https:\/\/www.youtube.com\/channel\/UCXgF-JqwBRGSawXajr6plGg"],"url":"https:\/\/www.couchbase.com\/blog\/ko\/author\/biozal\/"}]}},"acf":[],"authors":[{"term_id":9539,"user_id":77540,"is_guest":0,"slug":"biozal","display_name":"Aaron LaBeau - Principal Software Engineer","avatar_url":{"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2024\/09\/aaron-couchbase.jpg","url2x":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2024\/09\/aaron-couchbase.jpg"},"0":null,"1":"","2":"","3":"","4":"","5":"","6":"","7":"","8":""}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/posts\/12874","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\/77540"}],"replies":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/comments?post=12874"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/posts\/12874\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/media\/12893"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/media?parent=12874"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/categories?post=12874"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/tags?post=12874"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/ppma_author?post=12874"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}