@@ -137,7 +137,7 @@ index is getting initialized. During transaction processing, the indexes will au
137
137
as blocks are committed to the ledger.
138
138
139
139
CouchDB Configuration
140
- ----------------------
140
+ ---------------------
141
141
142
142
CouchDB is enabled as the state database by changing the ``stateDatabase `` configuration option from
143
143
goleveldb to CouchDB. Additionally, the ``couchDBAddress `` needs to configured to point to the
@@ -212,5 +212,35 @@ is to be changed after creation of the container.
212
212
213
213
.. note :: CouchDB peer options are read on each peer startup.
214
214
215
+ Good practices for queries
216
+ --------------------------
217
+
218
+ Avoid using chaincode for queries that will result in a scan of the entire
219
+ CouchDB database. Full length database scans will result in long response
220
+ times and will degrade the performance of your network. You can take some of
221
+ the following steps to avoid long queries:
222
+
223
+ - When using JSON queries:
224
+
225
+ * Be sure to create indexes in the chaincode package.
226
+ * Avoid query operators such as ``$or ``, ``$in `` and ``$regex ``, which lead
227
+ to full database scans.
228
+
229
+ - For range queries, composite key queries, and JSON queries:
230
+
231
+ * Utilize paging support (as of v1.3) instead of one large result set.
232
+
233
+ - If you want to build a dashboard or collect aggregate data as part of your
234
+ application, you can query an off-chain database that replicates the data
235
+ from your blockchain network. This will allow you to query and analyze the
236
+ blockchain data in a data store optimized for your needs, without degrading
237
+ the performance of your network or disrupting transactions. To achieve this,
238
+ applications may use block or chaincode events to write transaction data
239
+ to an off-chain database or analytics engine. For each block received, the block
240
+ listener application would iterate through the block transactions and build a
241
+ data store using the key/value writes from each valid transaction's ``rwset ``.
242
+ The :doc: `peer_event_services ` provide replayable events to ensure the
243
+ integrity of downstream data stores.
244
+
215
245
.. Licensed under Creative Commons Attribution 4.0 International License
216
- https://creativecommons.org/licenses/by/4.0/
246
+ https://creativecommons.org/licenses/by/4.0/
0 commit comments