-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve read performance for complicated queries by up to 50% (#3300)
* Add missing typecast in diffQueryAgainstStore. * Optimize merge function in graphql-anywhere. This is extremely hot code, so small improvements matter. Key observation: dest tends to be the current result object, which can have a lot of keys that are irrelevant to the keys from src that we're trying to merge, so the real win here is to avoid computing and iterating over the keys of dest. * Stop needlessly printing stored query documents. As you can see from these changes, we weren't using the printed query string for anything except error checking, and the query document object should suffice for that. * Stop using Object.defineProperty in resultMapper. I respectfully disagree with the comment about hiding the ID field, since the property is still discoverable in principle. If we really wanted to keep hiding it, we could do that only in development. Simple property assignment is not only faster than calling Object.defineProperty, but also makes subsequent usage of the object faster. Kind of a shame that defineProperty is still slow in 2018, but that's the world we live in. * Use Object.create(null) instead of {} for ObjectCache. If you're going to use an Object for a cache, you don't want keys like "toString" returning truthy values, and it's slightly faster to look up nonexistent keys if the prototype chain is shorter. * Optimize readStoreResolver. Not calling getStoreKeyName when we know it's just going to return its first argument unmodified makes a noticeable difference here. Not looking up values in an empty object {} also helps. * Update CHANGELOG.md files for PR #3300. * Add myself to the apollo-client/AUTHORS file. * Address feedback from @jamesreggio.
- Loading branch information
Showing
9 changed files
with
48 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters