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(mango): add keys_examined for execution_stats #4569

Merged

Conversation

pgj
Copy link
Contributor

@pgj pgj commented May 3, 2023

Add another field to the shard-level Mango execution statistics to keep track of the count of keys that were examined for the query. Note that this requires to change the way how stats are stored -- an approach similar to that of the view callback arguments was chosen, which features a map (#4394).

The change in the format also implies a potential incompatibility between different version of nodes, which may happen for mixed-version clusters. This is handled by introducing an additional option for the view callback where the coordinator can request for the results in the new format and the old format is still recognized. It helps to handle version differences automatically therefore no specific configuration option is required to control the migration. Thanks @rnewson for the idea.

This is related to the covering indexes work and takes inspiration from earlier works of @mikerhodes , see #4410 and #4413 for the details.

Note that slight increase in unit test coverage for mango_execution_stats due to the implicit testing via mango_cursor_view. The only missing part is incr_docs_examined/1 but that is not used from there, only from mango_cursor_text and mango_cursor_nouveau .

$ make eunit apps=mango

before:

[..]
Code Coverage:
[..]
mango_cursor_view     : 100%
[..]
mango_execution_stats :  63%
[..]
Total                 : 46%

after:

[..]
Code Coverage:
[..]
mango_cursor_view     : 100%
[..]
mango_execution_stats :  94%
[..]
Total                 : 47%

Checklist

  • Code is written and works correctly
  • Changes are covered by tests

@pgj pgj force-pushed the feat/mango-execution-stats-keys-examined branch 2 times, most recently from 98d47bc to 92febd4 Compare May 5, 2023 00:01
Copy link
Contributor

@nickva nickva left a comment

Choose a reason for hiding this comment

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

+1

Well done!

See a tiny stile nit and a question about adding an upgrade comment

@pgj pgj force-pushed the feat/mango-execution-stats-keys-examined branch 2 times, most recently from 604beef to 20eabcb Compare May 8, 2023 14:54
@pgj
Copy link
Contributor Author

pgj commented May 9, 2023

Please do not merge this now, I would like to do some refactoring (move the process dictionary function under mango_execution_stats) per @chewbranca's recommendations.

@pgj pgj force-pushed the feat/mango-execution-stats-keys-examined branch 2 times, most recently from 2e0d2f9 to 583e396 Compare May 9, 2023 23:15
@pgj
Copy link
Contributor Author

pgj commented May 10, 2023

OK -- the planned changes are there.

Copy link
Contributor

@chewbranca chewbranca left a comment

Choose a reason for hiding this comment

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

Awesome, @pgj! Thanks for moving the process dictionary manipulation to a dedicated module. I left a minor nit on assigning variables within a case statement, but otherwise looks good to me.

src/mango/src/mango_cursor_view.erl Outdated Show resolved Hide resolved
@pgj pgj force-pushed the feat/mango-execution-stats-keys-examined branch from 583e396 to 3ecd6a1 Compare May 10, 2023 17:35
@pgj pgj force-pushed the feat/mango-execution-stats-keys-examined branch from 3ecd6a1 to c39bd1d Compare May 10, 2023 18:25
Add another field to the shard-level Mango execution statistics
to keep track of the count of keys that were examined for the
query.  Note that this requires to change the way how stats are
stored -- an approach similar to that of the view callback
arguments was chosen, which features a map.

This current version supports both the old and new formats.  The
coordinator may request getting the results in the new one by
adding `execution_stats_map` for the arguments of the view
callback.  Otherwise the old format is used (without the extra
field), which makes it possible to work with older coordinators.
Old workers will automatically ignore this argument and answer in
the old format.
@pgj pgj force-pushed the feat/mango-execution-stats-keys-examined branch from c39bd1d to 2351468 Compare May 10, 2023 19:28
@chewbranca chewbranca merged commit 8600e46 into apache:main May 10, 2023
@pgj pgj deleted the feat/mango-execution-stats-keys-examined branch May 10, 2023 20:10
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.

4 participants