Skip to content
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

[Python] Remarks on result performance (eager vs lazy loading) #430

Merged
merged 2 commits into from
Jun 13, 2024

Conversation

stefano-ottolenghi
Copy link
Contributor

No description provided.

@stefano-ottolenghi stefano-ottolenghi marked this pull request as ready for review June 10, 2024 08:01
@stefano-ottolenghi stefano-ottolenghi changed the title Remarks on result performance (eager vs lazy loading) [Python] Remarks on result performance (eager vs lazy loading) Jun 10, 2024
@stefano-ottolenghi stefano-ottolenghi force-pushed the result-remark branch 2 times, most recently from ef24b18 to dde8674 Compare June 11, 2024 12:32
Copy link
Member

@robsdedude robsdedude left a comment

Choose a reason for hiding this comment

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

Gotta go (evenly) fast!

The Neo4j server can retrieve records in batches, and the driver can receive one batch and _wait_ until it has been processed by the application before receiving another one from the server.
Lazy-loading a result spreads out network traffic and memory usage.

For convenience, xref:query-simple.adoc[`.execute_query()`] always retrieves all result records at once (it is what the `Eager` in `EagerResult` stands for).
Copy link
Member

Choose a reason for hiding this comment

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

Well technically (off to a great start 🙃), you can get .execute_query to discard records instead of streaming them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I assume you mean with custom transformers?

Copy link
Member

Choose a reason for hiding this comment

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

Yep, exactly.

python-manual/modules/ROOT/pages/performance.adoc Outdated Show resolved Hide resolved
|Lazy loading

|
- The server has to read all 250 records from the storage before it can send even the first one the driver (i.e. it takes more time for the client to receive the first record).
Copy link
Member

Choose a reason for hiding this comment

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

Really? I expect the server to send the records in batches of the configured batch size.

Copy link
Member

Choose a reason for hiding this comment

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

Aha. I just kept reading. Eager loading also assumes you don't touch the batch size.

@neo-technology-commit-status-publisher
Copy link
Collaborator

Thanks for the documentation updates.

The preview documentation has now been torn down - reopening this PR will republish it.

@stefano-ottolenghi stefano-ottolenghi merged commit 953962c into dev Jun 13, 2024
5 checks passed
@stefano-ottolenghi stefano-ottolenghi deleted the result-remark branch June 13, 2024 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants