Skip to content

Optimize query execution by deferring query evaluation #3201

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

Merged
merged 29 commits into from
Dec 8, 2021

Conversation

schmidt-sebastian
Copy link
Contributor

Our current query pipeline is essentially as such:

  • The RemoteDocumentCache executes a query by scanning all documents in the collection. It reads all documents and removes documents that do not match the query.
  • The LocalDocumentsView then fetches all mutations that possibly apply.
  • If we fetch a mutation but don't have a document, we go back to the RemoteDocumentCache to fetch the documents that are missing - but these are the same documents that we filtered out in the initial step.

I think the idea behind this was that the RemoteDocumentCache uses the Query to filter the document it reads, but this code now lives in IndexManager. This PR therefore removes the "Query" functionality from the RemoteDocumentCache and instead just returns all documents from the collection.

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Dec 2, 2021

Coverage Report

Affected SDKs

  • firebase-firestore

    SDK overall coverage changed from 45.25% (1986969) to 45.21% (39959e7d) by -0.04%.

    Filename Base (1986969) Head (39959e7d) Diff
    MemoryRemoteDocumentCache.java 98.25% 98.08% -0.17%
    SQLiteRemoteDocumentCache.java 96.72% 96.46% -0.26%
    SetMutation.java 94.29% 97.14% +2.86%

Test Logs

Notes

HTML coverage reports can be produced locally with ./gradlew <product>:checkCoverage.
Report files are located at <product-build-dir>/reports/jacoco/.

Head commit (39959e7d) is created by Prow via merging commits: 1986969 c72063d.

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Dec 2, 2021

Binary Size Report

Affected SDKs

  • firebase-firestore

    Type Base (1986969) Head (39959e7d) Diff
    aar 1.23 MB 1.23 MB -647 B (-0.1%)
    apk (release) 3.33 MB 3.33 MB -124 B (-0.0%)

Test Logs

Notes

Head commit (39959e7d) is created by Prow via merging commits: 1986969 c72063d.

Copy link
Contributor

@dconeybe dconeybe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Just a few small comments.

Base automatically changed from mrschmidt/getnext to master December 8, 2021 20:19
@schmidt-sebastian schmidt-sebastian merged commit dfa2231 into master Dec 8, 2021
@schmidt-sebastian schmidt-sebastian deleted the mrschmidt/dontquery branch December 8, 2021 21:22
@firebase firebase locked and limited conversation to collaborators Jan 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants