15
15
* limitations under the License.
16
16
*/
17
17
18
+ import { getUA , isSafari } from '@firebase/util' ;
19
+
18
20
import {
19
21
LimitType ,
20
22
newQueryComparator ,
@@ -47,6 +49,7 @@ import { LocalDocumentsView } from './local_documents_view';
47
49
import { PersistencePromise } from './persistence_promise' ;
48
50
import { PersistenceTransaction } from './persistence_transaction' ;
49
51
import { QueryContext } from './query_context' ;
52
+ import { SimpleDb } from './simple_db' ;
50
53
51
54
const DEFAULT_INDEX_AUTO_CREATION_MIN_COLLECTION_SIZE = 100 ;
52
55
@@ -55,10 +58,19 @@ const DEFAULT_INDEX_AUTO_CREATION_MIN_COLLECTION_SIZE = 100;
55
58
* (([index, docKey] + [docKey, docContent]) per document in the result set)
56
59
* / ([docKey, docContent] per documents in full collection scan) coming from
57
60
* experiment [enter PR experiment URL here].
58
- * TODO(b/299284287) Choose a value appropriate for the browser/OS combination,
59
- * as determined by more data points from running the experiment.
60
61
*/
61
- const DEFAULT_RELATIVE_INDEX_READ_COST_PER_DOCUMENT = 8 ;
62
+ function getDefaultRelativeIndexReadCostPerDocument ( ) : number {
63
+ // These values were derived from an experiment where several members of the
64
+ // Firestore SDK team ran a performance test in various environments.
65
+ // Googlers can see b/299284287 for details.
66
+ if ( isSafari ( ) ) {
67
+ return 8 ;
68
+ } else if ( SimpleDb . getAndroidVersion ( getUA ( ) ) > 0 ) {
69
+ return 6 ;
70
+ } else {
71
+ return 4 ;
72
+ }
73
+ }
62
74
63
75
/**
64
76
* The Firestore query engine.
@@ -113,7 +125,7 @@ export class QueryEngine {
113
125
DEFAULT_INDEX_AUTO_CREATION_MIN_COLLECTION_SIZE ;
114
126
115
127
relativeIndexReadCostPerDocument =
116
- DEFAULT_RELATIVE_INDEX_READ_COST_PER_DOCUMENT ;
128
+ getDefaultRelativeIndexReadCostPerDocument ( ) ;
117
129
118
130
/** Sets the document view to query against. */
119
131
initialize (
0 commit comments