Issue
We are experiencing significant performance issues with Firestore queries that includes a where clause on a any fields (e.g., order_date) with or without a bounded range (>= and/or <=). Despite all required indexes being created and the result set being small or empty, the query consistently takes ~9 seconds to return. This happened to us only after upgrading the package to the latest version.
NOTE: We tried using the Firebase Web SDK and it takes significantly less time to load. using firebase version 11.6.1. However, we need the offline persistence, so we cannot migrate to the web sdk.
UPDATE: We tried to downgrade to @react-native-firebase/firestore version ^21.6.1 and it worked perfectly fine.
-- version 22.2.0 -- this takes 20.59511 seconds:
const path = `clients/{clientId}/branches/{branchId}/orders`;
const ref = collection(db, path);
const q = query(ref, where("isPaid","==",false), where("isVoid","==",false), where("order_status_id","==","new-order"), orderBy("order_date","desc"), limit(25));
const snapshot = await getDocs(q);
-- version 22.2.0 -- this takes 9.492874 seconds:
const path = `clients/{clientId}/branches/{branchId}/orders`;
const ref = collection(db, path);
const q = query(ref, where("isPaid","==",true), where("order_date",">=","2025-05-17T21:00:00.000Z"), where("order_date","<=","2025-05-18T10:55:39.388Z"), orderBy("order_date","desc"), limit(9));
const snapshot = await getDocs(q);
-- version 22.2.0 -- while this takes 0.654975 seconds:
const path = `clients/{clientId}/branches/{branchId}/orders`;
const ref = collection(db, path);
const q = query(ref, where("isPaid","==",true), orderBy("order_date","desc"), limit(9));
const snapshot = await getDocs(q);
Project Files
Javascript
Click To Expand
package.json:
{
"@react-native-firebase/app": "^22.2.0",
"@react-native-firebase/auth": "^22.2.0",
"@react-native-firebase/firestore": "^22.2.0",
"@react-native-firebase/storage": "^22.2.0"
}
firebase.json for react-native-firebase v6:
Android
Click To Expand
Have you converted to AndroidX?
android/build.gradle:
buildscript {
ext {
buildToolsVersion = "35.0.0" // Latest build tools
minSdkVersion = 26
compileSdkVersion = 35
targetSdkVersion = 35
if (System.properties['os.arch'] == "aarch64") {
// For M1 Users we need to use the NDK 24 which added support for aarch64
ndkVersion = "24.0.8215888"
} else {
// Otherwise we default to the side-by-side NDK version from AGP.
ndkVersion = "27.1.12297006"
}
googlePlayServicesAuthVersion = "20.7.0" // Latest Google Play Services
supportLibVersion = "28.0.0" // Legacy; consider replacing with AndroidX equivalents
kotlinVersion = "2.0.21" // Latest stable Kotlin version
kotlin_version = "2.0.21" // Latest stable Kotlin version
androidXCore = "1.10.1" // Latest androidx.core
}
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://developer.huawei.com/repo/' }
}
dependencies {
classpath('com.android.tools.build:gradle:8.1.0') // Matches Gradle version
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("de.undercouch:gradle-download-task:5.0.1")
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.15' // Latest Google services plugin
classpath 'com.huawei.agconnect:agcp:1.9.1.300' // Latest Huawei AGCP
}
}
allprojects {
repositories {
mavenLocal()
google()
jcenter()
mavenCentral()
maven { url 'https://jitpack.io' }
maven { url 'https://developer.huawei.com/repo/' }
}
// This is a fix for Android build error: 28/04/2025
configurations.all {
resolutionStrategy {
force 'org.bouncycastle:bcprov-jdk15to18:1.78.1'
exclude group: 'org.bouncycastle', module: 'bcprov-jdk15on'
}
}
}
configurations.all {
resolutionStrategy {
force 'androidx.core:core-ktx:1.10.1' // Force latest androidx core-ktx
}
}
apply plugin: "com.facebook.react.rootproject"
android/app/build.gradle:
android/settings.gradle:
MainApplication.java:
AndroidManifest.xml:
Environment
Click To Expand
react-native info output:
- Platform that you're experiencing the issue on:
react-native-firebase version you're using that has this issue:
Firebase module(s) you're using that has the issue:
@react-native-firebase/firestore
- Are you using
TypeScript?
Issue
We are experiencing significant performance issues with Firestore queries that includes a where clause on a any fields (e.g., order_date) with or without a bounded range (>= and/or <=). Despite all required indexes being created and the result set being small or empty, the query consistently takes ~9 seconds to return. This happened to us only after upgrading the package to the latest version.
NOTE: We tried using the Firebase Web SDK and it takes significantly less time to load. using firebase version
11.6.1. However, we need the offline persistence, so we cannot migrate to the web sdk.UPDATE: We tried to downgrade to
@react-native-firebase/firestoreversion^21.6.1and it worked perfectly fine.-- version 22.2.0 -- this takes 20.59511 seconds:
-- version 22.2.0 -- this takes 9.492874 seconds:
-- version 22.2.0 -- while this takes 0.654975 seconds:
Project Files
Javascript
Click To Expand
package.json:{ "@react-native-firebase/app": "^22.2.0", "@react-native-firebase/auth": "^22.2.0", "@react-native-firebase/firestore": "^22.2.0", "@react-native-firebase/storage": "^22.2.0" }firebase.jsonfor react-native-firebase v6:# N/AAndroid
Click To Expand
Have you converted to AndroidX?
android/gradle.settingsjetifier=truefor Android compatibility?jetifierfor react-native compatibility?android/build.gradle:buildscript { ext { buildToolsVersion = "35.0.0" // Latest build tools minSdkVersion = 26 compileSdkVersion = 35 targetSdkVersion = 35 if (System.properties['os.arch'] == "aarch64") { // For M1 Users we need to use the NDK 24 which added support for aarch64 ndkVersion = "24.0.8215888" } else { // Otherwise we default to the side-by-side NDK version from AGP. ndkVersion = "27.1.12297006" } googlePlayServicesAuthVersion = "20.7.0" // Latest Google Play Services supportLibVersion = "28.0.0" // Legacy; consider replacing with AndroidX equivalents kotlinVersion = "2.0.21" // Latest stable Kotlin version kotlin_version = "2.0.21" // Latest stable Kotlin version androidXCore = "1.10.1" // Latest androidx.core } repositories { google() jcenter() mavenCentral() maven { url 'https://developer.huawei.com/repo/' } } dependencies { classpath('com.android.tools.build:gradle:8.1.0') // Matches Gradle version classpath("com.facebook.react:react-native-gradle-plugin") classpath("de.undercouch:gradle-download-task:5.0.1") classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'com.google.gms:google-services:4.3.15' // Latest Google services plugin classpath 'com.huawei.agconnect:agcp:1.9.1.300' // Latest Huawei AGCP } } allprojects { repositories { mavenLocal() google() jcenter() mavenCentral() maven { url 'https://jitpack.io' } maven { url 'https://developer.huawei.com/repo/' } } // This is a fix for Android build error: 28/04/2025 configurations.all { resolutionStrategy { force 'org.bouncycastle:bcprov-jdk15to18:1.78.1' exclude group: 'org.bouncycastle', module: 'bcprov-jdk15on' } } } configurations.all { resolutionStrategy { force 'androidx.core:core-ktx:1.10.1' // Force latest androidx core-ktx } } apply plugin: "com.facebook.react.rootproject"android/app/build.gradle:// N/Aandroid/settings.gradle:// N/AMainApplication.java:// N/AAndroidManifest.xml:<!-- N/A -->Environment
Click To Expand
react-native infooutput:react-native-firebaseversion you're using that has this issue:22.2.0Firebasemodule(s) you're using that has the issue:@react-native-firebase/firestoreTypeScript?YReact Native FirebaseandInvertaseon Twitter for updates on the library.