Very slow query compilation on Xamarin Android

I am in the process of evaluating Couchbase Lite for my company.
In a bare-bones Xamarin Android app, I am adding a couple of small documents (just a handful of properties) and then running the following query:
using (var query = QueryBuilder
.Select(SelectResult.Property(nameof(Project.Name)))
.From(DataSource.Database(Database))
.Where(
Expression.Property(nameof(Project.Name)).Like(Expression.String($"%{searchTerm}%"))
))
{
var rows = query.Execute();

}
The query building is taking over 2 seconds to complete (actual query is fast).

I’ve tried a bunch of different variations of the query (select all instead, using parameterization, no where clause), but nothing has improved the speed.
I just remembered that I have encryption turned on, so I will try it without that and report back.

Additional info:
CBL 2.0 DB 22
Using Encryption
Using this index:
database.CreateIndex(“ProjectNameIndex”, IndexBuilder.ValueIndex(
ValueIndexItem.Expression(Expression.Property(nameof(Project.Name)))
));

Hmm… looks like it is the encryption causing the slow querying.

Curious if encryption is a requirement for your company ? We have been looking into encryption support in 2.0 and after careful evaluation of the implications of supporting it across platforms and on 1.x migration , it will likely to be moved to 2.1

The culprit here is the LIKE comparison. It can’t be sped up using an index, so the query has to load and scan every document in the database, with O(n) performance.

Consider using full-text search instead, which uses a different type of index that can efficiently find individual words in a string (but not arbitrary substrings.)

The query building is taking over 2 seconds to complete (actual query is fast).

The ‘building’ part is where the actual querying takes place. The enumeration part is just iterating over query results in RAM.

@priya.rajagopal - Encryption is a requirement.
@jens - Like I mentioned above, I tried a whole bunch of different queries, many without the LIKE or the WHERE altogether. The LIKE was not a factor. The number documents I was operating on was extremely small ( just 2, for most of my tests!).

Encryption should be available in 2.1. (CC @ssmotra) . It will be removed in next release of 2.0.
We will factor in evaluating the impact of encryption to query performance in our test plan.

Something’s very wrong, then. Any kind of query on a small number of documents should be instantaneous, with or without encryption. I can’t imagine what would be taking two seconds.


Can you provide us with a small test case that reproduce this? I'm pretty certain we've never seen this behavior.