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

feat: implement query profiling #542

Merged
merged 45 commits into from
Aug 7, 2024
Merged

feat: implement query profiling #542

merged 45 commits into from
Aug 7, 2024

Conversation

daniel-sanche
Copy link
Contributor

@daniel-sanche daniel-sanche commented May 20, 2024

Added Query Profiling, support, for retrieving information about a query

Query Profiling is configured through the new ExplainOptions dataclass, which can be attached to a Query or AggregationQuery object at init time.

ExplainOptions has one argument: analyze. When analyze is True, it runs the entire query, and returns a set of stats about the execution, and a set of "planning" data detailing the indexes used by the request. If analuze is False, only the planning data is returned, and the query is not executed

For usage details, see the new samples added as part of this PR

@product-auto-label product-auto-label bot added size: l Pull request size is large. api: datastore Issues related to the googleapis/python-datastore API. labels May 20, 2024
@product-auto-label product-auto-label bot removed the size: l Pull request size is large. label May 21, 2024
@daniel-sanche daniel-sanche added cla: yes This human has signed the Contributor License Agreement. cla: no This human has *not* signed the Contributor License Agreement. and removed cla: no This human has *not* signed the Contributor License Agreement. cla: yes This human has signed the Contributor License Agreement. labels Jul 29, 2024
@google-cla google-cla bot added cla: no This human has *not* signed the Contributor License Agreement. and removed cla: yes This human has signed the Contributor License Agreement. labels Jul 29, 2024
raise QueryExplainError("explain_options not set on query.")
elif self._aggregation_query._explain_options.analyze is False:
# we need to run the query to get the explain_metrics
self._next_page()
Copy link
Contributor Author

@daniel-sanche daniel-sanche Aug 2, 2024

Choose a reason for hiding this comment

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

Is this safe? (Are the results being returned later, or thrown out)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't have any results when analyze=True, so this is safe. Added comment

@daniel-sanche daniel-sanche added cla: yes This human has signed the Contributor License Agreement. and removed cla: no This human has *not* signed the Contributor License Agreement. labels Aug 7, 2024
@google-cla google-cla bot added cla: no This human has *not* signed the Contributor License Agreement. and removed cla: yes This human has signed the Contributor License Agreement. labels Aug 7, 2024
@daniel-sanche daniel-sanche added cla: yes This human has signed the Contributor License Agreement. and removed cla: no This human has *not* signed the Contributor License Agreement. labels Aug 7, 2024
@google-cla google-cla bot added cla: no This human has *not* signed the Contributor License Agreement. and removed cla: yes This human has signed the Contributor License Agreement. labels Aug 7, 2024
@daniel-sanche daniel-sanche added cla: yes This human has signed the Contributor License Agreement. and removed cla: no This human has *not* signed the Contributor License Agreement. labels Aug 7, 2024
@daniel-sanche daniel-sanche merged commit 1500f70 into main Aug 7, 2024
28 checks passed
@daniel-sanche daniel-sanche deleted the query_profiling branch August 7, 2024 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: datastore Issues related to the googleapis/python-datastore API. cla: yes This human has signed the Contributor License Agreement. size: xl Pull request size is extra large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants