I have a simple query that loads a list of Visa card transactions. I’m currently testing with a large list of 4922 TransactionFragments. (Queries & Fragments shown at bottom of this post).
As you can see from the following table: cold start queries from SQLiteNormalizedCache are an order of magnitude slower than doing a requery, and **CAN EVEN BE SLOWER THAN LOADING FRESH FROM THE BACKEND.
**
How do I fix this? I need to instantly run this query when the app opens (it’s the first thing the user sees) so I can’t preload.
TIMING
- Fresh load from backend (AWS, Node, Postgres): 4-8 seconds
- Cold start load from SQLiteNormalizedCache: 6 seconds
- Requery (after cold start) from SQLiteNormalizedCache: 0.95 seconds
- Query from InMemoryNormalizedCache: 0.72 seconds
I added return try? CacheKeyInfo(jsonValue: object["id"]) to my SchemaConfiguration and that changed nothing.
query Transactions($updatedSince: String) {
transactions(updatedSince: $updatedSince) {
endCursor
hasNext
totalTransactions
transactions {
…TransactionFragment
}
}
}
type TransactionFragment {
id: ID!
createdAt: String!
updatedAt: String!
deletedAt: String
transactionType: TransactionType!
transactionStatus: TransactionStatus
declineReason: String
actionRanAssignToEnvelopes: Boolean!
actionRanSendNotification: Boolean!
name: String!
nameOriginal: String
amount: Int!
merchantId: String
mcc: String
cardId: String
cardLast4: String
notes: String
checkId: String
checkDepositError: CheckDepositError
addressCity: String
addressState: String
addressZip: String
addressCountry: String
addressLine1: String
addressLine2: String
locationLat: String
locationLong: String
locationUnstructured: String
merchantLogo: String
merchantPhone: String
merchantWebsite: String
fundedByTransactionId: ID
toEnvelopeId: ID
fromEnvelopeId: ID
}