Question 1
A developer is troubleshooting a slow-performing chaincode query that uses a complex selector to find assets based on multiple JSON attributes. The underlying state database is CouchDB. What is the most effective way to improve the performance of this query?
Answer and explanation
Correct answer: C
CouchDB rich queries can be slow if they result in a full database scan. The recommended way to optimize them is to create a JSON index that covers the fields used in the selector. By creating an index on 'owner' and 'color', CouchDB can satisfy the query much more efficiently. These indexes should be defined in a .json file and placed in the META-INF/statedb/couchdb/indexes directory within the chaincode package, ensuring they are automatically deployed with the chaincode.