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

tenant: add missing index #1073

Merged
merged 2 commits into from Dec 14, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -33,6 +33,7 @@ CREATE TABLE tenant_kvs (
PRIMARY KEY(record_id)
) /*! CHARACTER SET utf8 COLLATE utf8_bin */;
CREATE INDEX tenant_kvs_key ON tenant_kvs(tenant_key);
CREATE INDEX tenant_kvs_trid_key ON tenant_kvs(tenant_record_id, tenant_key);
Copy link
Member

Choose a reason for hiding this comment

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

Do we still need the tenant_kvs_key index? Are we not always interested in searching for the tenant_key for a given tenant?

Copy link
Member Author

Choose a reason for hiding this comment

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

tl;dr: I think we can remove it indeed, I will update the PR.

With the index, results of the Ruby integration tests:

Finished in 1146.325216 seconds.

186 tests, 10161 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed

Indices usage for the table as reported by MySQL (server restarted before the test run):

mysql> select object_type, object_schema, object_name, index_name, count_star, count_read, count_write, count_fetch, count_insert, count_update, count_delete from performance_schema.table_io_waits_summary_by_index_usage where object_schema = 'killbill' and object_name = 'tenant_kvs';
+-------------+---------------+-------------+---------------------+------------+------------+-------------+-------------+--------------+--------------+--------------+
| object_type | object_schema | object_name | index_name          | count_star | count_read | count_write | count_fetch | count_insert | count_update | count_delete |
+-------------+---------------+-------------+---------------------+------------+------------+-------------+-------------+--------------+--------------+--------------+
| TABLE       | killbill      | tenant_kvs  | PRIMARY             |        210 |        210 |           0 |         210 |            0 |            0 |            0 |
| TABLE       | killbill      | tenant_kvs  | record_id           |          0 |          0 |           0 |           0 |            0 |            0 |            0 |
| TABLE       | killbill      | tenant_kvs  | tenant_kvs_trid_key |       2250 |       2244 |           6 |        2244 |            0 |            6 |            0 |
| TABLE       | killbill      | tenant_kvs  | tenant_kvs_key      |          0 |          0 |           0 |           0 |            0 |            0 |            0 |
| TABLE       | killbill      | tenant_kvs  | NULL                |        209 |          0 |         209 |           0 |          209 |            0 |            0 |
+-------------+---------------+-------------+---------------------+------------+------------+-------------+-------------+--------------+--------------+--------------+
5 rows in set (0.04 sec)

Without the index:

Finished in 1151.187477 seconds.

186 tests, 10161 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed

Indices usage (server restarted before the test run):

mysql> select object_type, object_schema, object_name, index_name, count_star, count_read, count_write, count_fetch, count_insert, count_update, count_delete from performance_schema.table_io_waits_summary_by_index_usage where object_schema = 'killbill' and object_name = 'tenant_kvs';
+-------------+---------------+-------------+---------------------+------------+------------+-------------+-------------+--------------+--------------+--------------+
| object_type | object_schema | object_name | index_name          | count_star | count_read | count_write | count_fetch | count_insert | count_update | count_delete |
+-------------+---------------+-------------+---------------------+------------+------------+-------------+-------------+--------------+--------------+--------------+
| TABLE       | killbill      | tenant_kvs  | PRIMARY             |        210 |        210 |           0 |         210 |            0 |            0 |            0 |
| TABLE       | killbill      | tenant_kvs  | record_id           |          0 |          0 |           0 |           0 |            0 |            0 |            0 |
| TABLE       | killbill      | tenant_kvs  | tenant_kvs_trid_key |       2255 |       2249 |           6 |        2249 |            0 |            6 |            0 |
| TABLE       | killbill      | tenant_kvs  | NULL                |        209 |          0 |         209 |           0 |          209 |            0 |            0 |
+-------------+---------------+-------------+---------------------+------------+------------+-------------+-------------+--------------+--------------+--------------+
4 rows in set (0.03 sec)



DROP TABLE IF EXISTS tenant_broadcasts;
Expand Down
@@ -0,0 +1 @@
CREATE INDEX tenant_kvs_trid_key ON tenant_kvs(tenant_record_id, tenant_key);