pouchdb queries are very slow on mobile app react native expo
- Dominant language
- JavaScript
- Stars
- 17.6k
- Forks
- 1.5k
- PR merge metrics
- No merged PRs in 30d
Description
### Issue
I am using pouchdb db form react native expo app and expo-sqlite as an adapter, but the problem is queries are very slow on mobile device as compare to browser.
find query take take 6 minutes to execute without indexes, if I create indexes , createIndex() takes 10 minutes to execute
allDocs is compareablly fast but still it takes 10 seconds to fetch 34000 docs which takes less than 1 second in the browser.
i dont know if this is how pouchdb suppose to work on mobile devices or I am doing something wrong
here is my configuration code
```
// import "react-native-get-random-values";
import PouchDB from "pouchdb-core";
// import rel from "relational-pouch";
import find from "pouchdb-find";
import HttpPouch from "pouchdb-adapter-http";
import replication from "pouchdb-replication";
import mapreduce from "pouchdb-mapreduce";
import SQLiteAdapterFactory from "pouchdb-adapter-react-native-sqlite";
import * as SQLite from "expo-sqlite";
import pouchdbLoad from "pouchdb-load";
import { polyfillWebCrypto } from "expo-standard-web-crypto";
const SQLiteAdapter = SQLiteAdapterFactory(SQLite);
import rel from "./relational-pouch";
polyfillWebCrypto();
PouchDB.plugin(HttpPouch)
.plugin(replication)
.plugin(mapreduce)
.plugin(pouchdbLoad)
.plugin(SQLiteAdapter)
.plugin(find)
.plugin(rel);
const localdb = new PouchDB("siloc", {
adapter: "react-native-sqlite",
auto_compaction: true
});
const remotedb = new PouchDB("https://v2.domain.xyz/siloc", {
auth: {
username: ***
password: ***,
},
});
```
### Info
- Environment: : React native expo sdk 49
- Platform: Android
- Adapter: "react-native-sqlite",
- Server: couchdb server
### Reproduce
try pouchdb with expo-sqlite
Contributor guide
Research direction
Start by reproducing the reported timings on Android with Expo SDK 49 and the shown react-native-sqlite configuration. Compare find, createIndex, and allDocs performance with and without indexes, then determine whether the behavior is expected for this adapter or points to a reproducible adapter problem; the issue is done only when the cause and an actionable next step are established.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react-native, sqlite
- Domain
- databases, mobile
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100