Hello Couchbase Forum,
We use Couchbase and CBL for over 3 years now and one thing always bothered. When we execute queries to read entries from expressions over keys, the execution of the Couchbase query is decreasing the performance of our apps significantly. E. g. we have 25000 data entries with relatively small documents in our CBL. Reading 100 of these entries takes 0.5 seconds which is unacceptable for our application. The documents contain only very small JSON documents. We could theoretically read all the data into objects once at the start of the database to execute only one query and manage data in Swift documents which we actually did a while ago but this is not the idea of a local database if I am not mistaking, it would make the CBL pretty much useless. Is there anything we miss about building the query or general Couchbase? How can we read the data faster?
I am writing here hoping that we miss something about Couchbase because executing these queries with SQL seems much faster. The execution time I mention is of course different on different devices but on every device I use it is approximately half a second and this is much too slow for 100 entries
Example keys of database entries
SomeKeyPrefix::0
SomeKeyPrefix::1
SomeKeyPrefix::2
SomeKeyPrefix::3
…
SomeKeyPrefix::100 //approximately 100 on other prefixes more or less
Time different tasks consume
(1) Takes 0.5 seconds
(2) Takes 0.0001 seconds
Running multiple of such queries takes forever
Here the code we use in Swift:
let ourDocumentKeyPrefix = "SomeKeyPrefix"
let query = QueryBuilder
.select(
SelectResult.all(),
SelectResult.expression(Meta.id)
)
.from(DataSource.database(database!))
.where(Meta.id.like(Expression.string(\(ourDocumentKeyPrefix)::%"))
)
do {
for result in try query.execute() { **//(1)** executing Couchbase query
**//(2)** my extraction data code here....
}
} catch {
}