Hi there,
I have the following situation. When I run this code (with commenting out “table1” existence query part) cursor.getCount()
takes only several hundred milliseconds (728, 824, 639 ms) on SQLCipher 4.0.1. If I remove comments, so table existence query is also executed then cursorExist.getCount()
takes only several milliseconds (most of the time only 1ms) but it causes the cursor.getCount()
to be executed in about 1 minute (66324, 60798, 68245 ms). I don’t know why. On SQLCipher 3.5.3 everything was OK, so cursor.getCount()
always runs fast, but on 3.5.9 it is even slower than on 4.0.1. Note that `table1’ table contains 37,777 lines of rows and 33 columns. Could someone help me to understand why querying table for existence causes the main query to degrade drastically? I even run EXPLAIN QUERY PLAN and EXPLAIN, but does not give any difference between queries.
/*
Cursor cursorExist = db.rawQuery("SELECT name FROM sqlite_master WHERE type='table' AND name='table1'", new String[]{});
long timeExist = System.currentTimeMillis();
cursorExist.getCount();
IOUtils.closeQuietly(cursorExist);
Log.d("query_performance", "queryAll: " + (System.currentTimeMillis() - timeExist));
*/
Cursor cursor = db.rawQuery("SELECT col1, col2, col3, _id FROM table1 ORDER BY _id", new String[]{});
long time = System.currentTimeMillis();
cursor.getCount();
Log.d("query_performance", "queryAll: " + (System.currentTimeMillis() - time));