@@ -63,7 +63,7 @@ class InnerDatabaseFile : public SQLiteVFS::File {
63
63
64
64
std::unique_ptr<SQLite::Database> outer_db_;
65
65
std::string inner_db_pages_table_;
66
- bool read_only_;
66
+ bool read_only_, web_ ;
67
67
68
68
std::string btree_interior_index_;
69
69
@@ -194,10 +194,12 @@ class InnerDatabaseFile : public SQLiteVFS::File {
194
194
FetchJob (InnerDatabaseFile &that)
195
195
: cursor(*(that.outer_db_), "SELECT pageno, data, meta1, meta2 FROM " +
196
196
that.inner_db_pages_table_ +
197
- " WHERE pageno >= ? ORDER BY pageno"),
197
+ " NOT INDEXED WHERE pageno >= ? ORDER BY pageno"),
198
198
page_size(that.page_size_) {
199
199
PutState (State::NEW);
200
- if (!that.btree_interior_index_ .empty ()) {
200
+ // prepare to read from btree interior index in web mode only. it can be
201
+ // counterproductive locally due to its big index keys => low fan-out
202
+ if (that.web_ && !that.btree_interior_index_ .empty ()) {
201
203
btree_interior_cursor.reset (new SQLite::Statement (
202
204
*(that.outer_db_ ), " SELECT pageno, data, meta1, meta2 FROM " +
203
205
that.inner_db_pages_table_ + " INDEXED BY " +
@@ -248,6 +250,7 @@ class InnerDatabaseFile : public SQLiteVFS::File {
248
250
#ifndef NDEBUG
249
251
non_sequential++;
250
252
#endif
253
+
251
254
// first try the covering index of interior btree pages
252
255
if (btree_interior_cursor &&
253
256
(btree_interior_cursor->reset (), btree_interior_cursor->bind (1 , pageno),
@@ -259,6 +262,7 @@ class InnerDatabaseFile : public SQLiteVFS::File {
259
262
} else {
260
263
// otherwise seek the main cursor
261
264
ResetCursor ();
265
+
262
266
cursor.bind (1 , pageno);
263
267
}
264
268
} else {
@@ -1071,6 +1075,7 @@ class InnerDatabaseFile : public SQLiteVFS::File {
1071
1075
bool noprefetch, bool web)
1072
1076
: outer_db_(std::move(outer_db)),
1073
1077
inner_db_pages_table_ (inner_db_tablename_prefix + " pages" ), read_only_(read_only),
1078
+ web_(web),
1074
1079
// MAX(pageno) instead of COUNT(pageno) because the latter would trigger table scan
1075
1080
select_page_count_(*outer_db_,
1076
1081
" SELECT IFNULL(MAX(pageno), 0) FROM " + inner_db_pages_table_),
@@ -1149,7 +1154,7 @@ class VFS : public SQLiteVFS::Wrapper {
1149
1154
for (const auto &p : ddl) {
1150
1155
SQLite::Statement (db, p.first + inner_db_tablename_prefix_ + p.second ).executeStep ();
1151
1156
}
1152
- if (!sqlite3_uri_boolean (zName, " no_btree_interior_index " , 0 )) {
1157
+ if (!sqlite3_uri_boolean (zName, " web_nodbi " , 0 )) {
1153
1158
// covering index of interior btree pages
1154
1159
SQLite::Statement (db, " CREATE INDEX " + inner_db_tablename_prefix_ +
1155
1160
" pages_btree_interior ON " + inner_db_tablename_prefix_ +
0 commit comments