|
| 1 | +.. Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| 2 | +.. use this file except in compliance with the License. You may obtain a copy of |
| 3 | +.. the License at |
| 4 | +.. |
| 5 | +.. http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | +.. |
| 7 | +.. Unless required by applicable law or agreed to in writing, software |
| 8 | +.. distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 9 | +.. WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 10 | +.. License for the specific language governing permissions and limitations under |
| 11 | +.. the License. |
| 12 | +
|
| 13 | +.. _api/partioned-dbs: |
| 14 | + |
| 15 | +===================== |
| 16 | +Partitioned Databases |
| 17 | +===================== |
| 18 | + |
| 19 | +Partitioned databases allow for data colocation in a cluster, which provides |
| 20 | +significant performance improvements for queries constrained to a single |
| 21 | +partition. |
| 22 | + |
| 23 | +See the guide for |
| 24 | +:ref:`getting started with partitioned databases <partitioned-dbs>` |
| 25 | + |
| 26 | +``/db/_partition/partition`` |
| 27 | +============================ |
| 28 | + |
| 29 | +.. http:get:: /{db}/_partition/{partition} |
| 30 | + :synopsis: Returns document and size info for the given partition |
| 31 | + |
| 32 | + This endpoint returns information describing the provided partition. |
| 33 | + It includes document and deleted document counts along with external |
| 34 | + and active data sizes. |
| 35 | + |
| 36 | + :code 200: Request completed successfully |
| 37 | + |
| 38 | + **Request**: |
| 39 | + |
| 40 | + .. code-block:: http |
| 41 | +
|
| 42 | + GET /db/_partition/foo HTTP/1.1 |
| 43 | + Accept: application/json |
| 44 | + Host: localhost:5984 |
| 45 | +
|
| 46 | + **Response**: |
| 47 | + |
| 48 | + .. code-block:: http |
| 49 | +
|
| 50 | + HTTP/1.1 200 OK |
| 51 | + Cache-Control: must-revalidate |
| 52 | + Content-Length: 119 |
| 53 | + Content-Type: application/json |
| 54 | + Date: Thu, 24 Jan 2019 17:19:59 GMT |
| 55 | + Server: CouchDB/2.3.0-a1e11cea9 (Erlang OTP/21) |
| 56 | +
|
| 57 | + { |
| 58 | + "db_name": "my_new_db", |
| 59 | + "doc_count": 1, |
| 60 | + "doc_del_count": 0, |
| 61 | + "partition": "sensor-260", |
| 62 | + "sizes": { |
| 63 | + "active": 244, |
| 64 | + "external": 347 |
| 65 | + } |
| 66 | + } |
| 67 | +
|
| 68 | +
|
| 69 | +``/db/_partition/partition/_all_docs`` |
| 70 | +====================================== |
| 71 | + |
| 72 | +.. http:get:: /{db}/_partition/{partition}/_all_docs |
| 73 | + :synopsis: Return all docs in the specified partition |
| 74 | + |
| 75 | + :param db: Database name |
| 76 | + :param partition: Partition name |
| 77 | + |
| 78 | + This endpoint is a convenience endpoint for automatically setting |
| 79 | + bounds on the provided partition range. Similar results can be had |
| 80 | + by using the global ``/db/_all_docs`` end point with appropriately |
| 81 | + configured values for ``start_key`` and ``end_key``. |
| 82 | + |
| 83 | + Refer to the :ref:`view endpoint <api/ddoc/view>` documentation for |
| 84 | + a complete description of the available query parameters and the format |
| 85 | + of the returned data. |
| 86 | + |
| 87 | + **Request**: |
| 88 | + |
| 89 | + .. code-block:: http |
| 90 | +
|
| 91 | + GET /db/_partition/sensor-260/_all_docs HTTP/1.1 |
| 92 | + Accept: application/json |
| 93 | + Host: localhost:5984 |
| 94 | +
|
| 95 | + **Response**: |
| 96 | + |
| 97 | + .. code-block:: http |
| 98 | +
|
| 99 | + HTTP/1.1 200 OK |
| 100 | + Cache-Control: must-revalidate |
| 101 | + Content-Type: application/json |
| 102 | + Date: Sat, 10 Aug 2013 16:22:56 GMT |
| 103 | + ETag: "1W2DJUZFZSZD9K78UFA3GZWB4" |
| 104 | + Server: CouchDB (Erlang/OTP) |
| 105 | + Transfer-Encoding: chunked |
| 106 | +
|
| 107 | + { |
| 108 | + "offset": 0, |
| 109 | + "rows": [ |
| 110 | + { |
| 111 | + "id": "sensor-260:sensor-reading-ca33c748-2d2c-4ed1-8abf-1bca4d9d03cf", |
| 112 | + "key": "sensor-260:sensor-reading-ca33c748-2d2c-4ed1-8abf-1bca4d9d03cf", |
| 113 | + "value": { |
| 114 | + "rev": "1-05ed6f7abf84250e213fcb847387f6f5" |
| 115 | + } |
| 116 | + } |
| 117 | + ], |
| 118 | + "total_rows": 1 |
| 119 | + } |
| 120 | +
|
| 121 | +
|
| 122 | +
|
| 123 | +``/db/_partition/partition/_design/design-doc/_view/view-name`` |
| 124 | +=============================================================== |
| 125 | + |
| 126 | +.. http:get:: /{db}/_partition/{partition}/_design/{ddoc}/_view/{view} |
| 127 | + :synopsis: Execute a partitioned query |
| 128 | + |
| 129 | + :param db: Database name |
| 130 | + :param partition: Partition name |
| 131 | + :param ddoc: Design document id |
| 132 | + :param view: View name |
| 133 | + |
| 134 | + This endpoint is responsible for executing a partitioned query. The |
| 135 | + returned view result will only contain rows with the specified |
| 136 | + partition name. |
| 137 | + |
| 138 | + Refer to the :ref:`view endpoint <api/ddoc/view>` documentation for |
| 139 | + a complete description of the available query parameters and the format |
| 140 | + of the returned data. |
| 141 | + |
| 142 | + .. code-block:: http |
| 143 | +
|
| 144 | + GET /db/_partition/sensor-260/_design/sensor-readings/_view/by_sensor HTTP/1.1 |
| 145 | + Accept: application/json |
| 146 | + Host: localhost:5984 |
| 147 | +
|
| 148 | + **Response**: |
| 149 | + |
| 150 | + .. code-block:: http |
| 151 | +
|
| 152 | + HTTP/1.1 200 OK |
| 153 | + Cache-Control: must-revalidate |
| 154 | + Content-Type: application/json |
| 155 | + Date: Wed, 21 Aug 2013 09:12:06 GMT |
| 156 | + ETag: "2FOLSBSW4O6WB798XU4AQYA9B" |
| 157 | + Server: CouchDB (Erlang/OTP) |
| 158 | + Transfer-Encoding: chunked |
| 159 | +
|
| 160 | +
|
| 161 | + { |
| 162 | + "offset": 0, |
| 163 | + "rows": [ |
| 164 | + { |
| 165 | + "id": "sensor-260:sensor-reading-ca33c748-2d2c-4ed1-8abf-1bca4d9d03cf", |
| 166 | + "key": [ |
| 167 | + "sensor-260", |
| 168 | + "0" |
| 169 | + ], |
| 170 | + "value": null |
| 171 | + }, |
| 172 | + { |
| 173 | + "id": "sensor-260:sensor-reading-ca33c748-2d2c-4ed1-8abf-1bca4d9d03cf", |
| 174 | + "key": [ |
| 175 | + "sensor-260", |
| 176 | + "1" |
| 177 | + ], |
| 178 | + "value": null |
| 179 | + }, |
| 180 | + { |
| 181 | + "id": "sensor-260:sensor-reading-ca33c748-2d2c-4ed1-8abf-1bca4d9d03cf", |
| 182 | + "key": [ |
| 183 | + "sensor-260", |
| 184 | + "2" |
| 185 | + ], |
| 186 | + "value": null |
| 187 | + }, |
| 188 | + { |
| 189 | + "id": "sensor-260:sensor-reading-ca33c748-2d2c-4ed1-8abf-1bca4d9d03cf", |
| 190 | + "key": [ |
| 191 | + "sensor-260", |
| 192 | + "3" |
| 193 | + ], |
| 194 | + "value": null |
| 195 | + } |
| 196 | + ], |
| 197 | + "total_rows": 4 |
| 198 | + } |
0 commit comments