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

ES-2276 | support level 2 query profiling #355

Merged
merged 2 commits into from
Dec 10, 2024
Merged

ES-2276 | support level 2 query profiling #355

merged 2 commits into from
Dec 10, 2024

Conversation

aMahanna
Copy link
Member

@aMahanna aMahanna commented Dec 6, 2024

  • Introduces support for setting the profile parameter in db.aql.execute to 2, which returns additional nodes information via cursor.statistics(), along with the query execution plan (newly available via cursor.plan())
  • Warrants an 8.2.0 release
pip install git+https://github.com/arangodb/python-arango@ES-2276
from arango import ArangoClient

db = ArangoClient().db()

cursor_a = db.aql.execute('FOR d IN doc SORT d._key RETURN d', profile=True)
cursor_b = db.aql.execute('FOR d IN doc SORT d._key RETURN d', profile=1)
cursor_c = db.aql.execute('FOR d IN doc SORT d._key RETURN d', profile=2)

assert cursor_a.statistics().keys() == cursor_b.statistics().keys()
assert cursor_a.profile().keys() == cursor_b.profile().keys()
assert cursor_a.plan() == cursor_b.plan() == None
assert "nodes" not in cursor_a.statistics()

assert cursor_c.plan().keys() == {'nodes', 'estimatedNrItems', 'collections', 'rules', 'variables', 'isModificationQuery', 'estimatedCost'}
assert "nodes" in cursor_c.statistics()

Comment on lines +137 to +139
if "plan" in extra:
self._plan = extra["plan"]
result["plan"] = extra["plan"]
Copy link
Member Author

@aMahanna aMahanna Dec 6, 2024

Choose a reason for hiding this comment

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

we're starting to blur the lines between camelCase & snake_case results...

plan is a dictionary, with some fields (such as nodes or variables) being list of dictionaries, whose fields can widely vary from each other (i.e one node dictionary may not have the same fields as another node dictionary).

It becomes a slippery slope trying to convert every single field within the nodes & variables dictionaries into snake_case, so I'm opting towards just returning the camelCase fields as-is.

Similar conversation here: #321 (review)

@aMahanna aMahanna requested a review from apetenchea December 6, 2024 17:44
@aMahanna aMahanna merged commit 0d56bcf into main Dec 10, 2024
37 checks passed
@aMahanna aMahanna deleted the ES-2276 branch December 10, 2024 14:03
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.

1 participant