Quickly accessing composite keys without range query #fabric-chaincode #fabric-questions
Hi guys, Here, I have to perform query based on partial composite key (It is a range querry correct?), which seems inefficient (comparatively slower) for fetching a data set by primary identifier. I've been thinking to have a in-memory cache which can store a map of ids and full composite keys, so that it is at least faster when same id is queried for second time in short period of time by avoiding range query to find full composite key. Then, how will I let the peers know, that the transaction has actually successfully added to block, before I add a particular key - composite-key to the in-memory map? Is there a way to add handlers at peer like this?: https://github.com/hyperledger/fabric/blob/release-1.4/core/handlers/auth/filter/expiration.go (Thanks Yacov for showing me this.) Any suggestions, even a different approach is very much welcomed and appreciated. I would also love to know if level db is already doing a good job in indexing this (I am not well aware of how level db works internally)
|
|
David Enyeart
goleveldb stores keys in sorted order. Therefore key queries and key range queries (such as those used under the covers for chaincode composite key queries) are both extremely efficient and have similar performance. Hi guys, I have been using leveldb as the state database for my application and use golang for chaincode. Here, to do a query of a field of a struct other than the key / primary identifier, I chose to use composite keys, where I flatten up the struct's fields into composite key before storing. So, each type of struct will have a different composite index name. Here, I have to perform query based on partial composite key (It is a range querry correct?), which seems inefficient (comparatively slower) for fetching a data set by primary identifier. I've been thinking to have a in-memory cache which can store a map of ids and full composite keys, so that it is at least faster when same id is queried for second time in short period of time by avoiding range query to find full composite key. Then, how will I let the peers know, that the transaction has actually successfully added to block, before I add a particular key - composite-key to the in-memory map? Is there a way to add handlers at peer like this?: https://github.com/hyperledger/fabric/blob/release-1.4/core/handlers/auth/filter/expiration.go (Thanks Yacov for showing me this.) Any suggestions, even a different approach is very much welcomed and appreciated. I would also love to know if level db is already doing a good job in indexing this (I am not well aware of how level db works internally)
|
|
Oh, is it? Thanks for reply David. On Tue, 10 Dec 2019, 7:02 pm David Enyeart, <enyeart@...> wrote:
|
|