Created index for zipkin_annotations, so DEPENDENCIES can run faster #1471
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Having 238460 rows inside zipkin_annotations, show this benefit :
BEFORE
mysql> explain SELECT
trace_id_high,
trace_id,
parent_id,
id,
a_key,
endpoint_service_name` FROM (select distinct s.trace_id_high, s.trace_id, s.parent_id, s.id, a.a_key, a.endpoint_service_name from zipkin_spans s left outer join zipkin_annotations a on (s.trace_id = a.trace_id and s.id = a.span_id and a.a_key in ('ca', 'cs', 'sr', 'sa')) where s.start_ts between 1483401600000000 and 1483487999999999 group by s.trace_id_high, s.trace_id, s.id, a.a_key, a.endpoint_service_name) as link_spans;| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
| 1 | PRIMARY | | ALL | NULL | NULL | NULL | NULL | 2529761520| |
| 2 | DERIVED | s | ALL | start_ts | NULL | NULL | NULL | 94380 | Using where; Using temporary |
| 2 | DERIVED | a | ALL | a_key | NULL | NULL | NULL | 236871 | Using where; Using join buffer (flat, BNL join) |
`
AFTER
mysql> explain SELECT
trace_id_high,
trace_id,
parent_id,
id,
a_key,
endpoint_service_name` FROM (select distinct s.trace_id_high, s.trace_id, s.parent_id, s.id, a.a_key, a.endpoint_service_name from zipkin_spans s left outer join zipkin_annotations a on (s.trace_id = a.trace_id and s.id = a.span_id and a.a_key in ('ca', 'cs', 'sr', 'sa')) where s.start_ts between 1483401600000000 and 1483487999999999 group by s.trace_id_high, s.trace_id, s.id, a.a_key, a.endpoint_service_name) as link_spans;| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
| 1 | PRIMARY | | ALL | NULL | NULL | NULL | NULL | 47190 | |
| 2 | DERIVED | s | ALL | start_ts | NULL | NULL | NULL | 94380 | Using where; Using temporary |
| 2 | DERIVED | a | ref | a_key,akey | akey | 16 | zipkin.s.trace_id,zipkin.s.id | 1 | Using where |
`
As you can see, rows seeked went from 2529761520 to a mere 47190.