-
Notifications
You must be signed in to change notification settings - Fork 653
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
Sql cache: use a single transaction when using MemoryCache chaining #5840
Conversation
✅ Deploy Preview for apollo-android-docs canceled.
|
@@ -43,6 +43,7 @@ actual class SqlNormalizedCacheFactory actual constructor( | |||
object : AndroidSqliteDriver.Callback(getSchema(withDates)) { | |||
override fun onConfigure(db: SupportSQLiteDatabase) { | |||
super.onConfigure(db) | |||
db.enableWriteAheadLogging() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the impact for existing databases? Can this be enabled on a database that wasn't using WAL previously?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great question! 👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe turn this into 2 separate PRs? One for transactions, one for WAL?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tested that opening a db created without WAL and enabling WAL on it works without an issue.
Opened a separate PR: #5843
val changedKeys = records.flatMap { record -> internalMerge(record, cacheHeaders, recordMerger) }.toSet() | ||
changedKeys + nextCache?.merge(records, cacheHeaders, recordMerger).orEmpty() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
deab18b
to
d271ab7
Compare
…ios12-compat * commit 'b8e8bdba951b1cb9beecabfc80433d848b2c921b': (38 commits) release 3.8.5 Fix mapping of the builtin Float scalar type (apollographql#6047) SqlNormalizedCacheFactory make sqldriver public to support Sqlcipher data encryption. (apollographql#5972) Update 08-add-a-details-view.mdx for additional state handling (apollographql#5975) adding checks for json end_document in http batching interceptors (apollographql#5892) adding checks for json end_document in http transport (apollographql#5894) [3.x] Bump okio to 3.9.0 (apollographql#5868) version is now 3.8.5-SNAPSHOT release 3.8.4 Backport apollographql#5848 to the v3 branch (apollographql#5863) Backport apollographql#5840 to the v3 branch (apollographql#5861) Backport apollographql#5778 to the v3 branch (apollographql#5860) Update min version of Kotlin in README and doc (apollographql#5750) version is now 3.8.4-SNAPSHOT release 3.8.3 Add deprecations on symbols that are getting removed in v4 (apollographql#5746) docs: Correct file name discrepancies in tutorial documentation (apollographql#5740) Ignore IOException when calling ApolloHttpCache.remove (apollographql#5730) Added an implementation of a missing NSURLSessionWebSocketDelegateProtocol method in the NSURLSessionWebSocketEngine that's required in order to get a web socket to successfully reopen. (apollographql#5704) Update plugin-configuration.mdx (apollographql#5673) ... # Conflicts: # gradle.properties # libraries/apollo-runtime/src/appleMain/kotlin/com/apollographql/apollo3/network/ws/NSURLSessionWebSocketEngine.kt
A single transaction is used in
merge(records: Collection<Record>)
, butmerge(record: Record)
was called instead when using memory cache chaining, resulting in using 1 transaction per insert (significantly slower).Also - enable WAL by default. This has no noticeable perf impact with the fix above (single transaction), but showed significant improvement without it.(moved to its own PR)Related to #5834