Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pouchdb queries are very slow on mobile app react native expo #8853

Open
bilalswiftsolutions opened this issue Feb 1, 2024 · 1 comment
Open

Comments

@bilalswiftsolutions
Copy link

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

@Mica4DEV
Copy link

Just a question to add more context, why would you do a SELECT * FROM table on 34 000 records in a real world scenario in the first place ?

Do you have an example of documents that you have stored in the database and the createIndex that you're trying to execute ?

If you change the default adapter does it change something in the performance issue you're having?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants