Skip to content

Instantly share code, notes, and snippets.

@kuzmik kuzmik/explain.sql
Created Mar 3, 2017

Embed
What would you like to do?
kuzmik:sentry_production> describe SELECT (sentry_groupedmessage.first_seen) AS `sort_by`, `sentry_groupedmessage`.`id`, `sentry_groupedmessage`.`project_id`, `sentry_groupedmessage`.`logger`, `sentry_groupedmessage`.`level`, `sentry_groupedmessage`.`message`, `sentry_groupedmessage`.`view`, `sentry_groupedmessage`.`num_comments`, `sentry_groupedmessage`.`platform`, `sentry_groupedmessage`.`status`, `sentry_groupedmessage`.`times_seen`, `sentry_groupedmessage`.`last_seen`, `sentry_groupedmessage`.`first_seen`, `sentry_groupedmessage`.`first_release_id`, `sentry_groupedmessage`.`resolved_at`, `sentry_groupedmessage`.`active_at`, `sentry_groupedmessage`.`time_spent_total`, `sentry_groupedmessage`.`time_spent_count`, `sentry_groupedmessage`.`score`, `sentry_groupedmessage`.`is_public`, `sentry_groupedmessage`.`data`, `sentry_groupedmessage`.`short_id`, `sentry_project`.`id`, `sentry_project`.`slug`, `sentry_project`.`name`, `sentry_project`.`forced_color`, `sentry_project`.`organization_id`, `sentry_project`.`team_id`, `sentry_project`.`public`, `sentry_project`.`date_added`, `sentry_project`.`status`, `sentry_project`.`first_event` FROM `sentry_groupedmessage` INNER JOIN `sentry_project` ON ( `sentry_groupedmessage`.`project_id` = `sentry_project`.`id` ) WHERE (`sentry_groupedmessage`.`status` = 0 AND `sentry_groupedmessage`.`active_at` >= '2017-02-23 22:41:44' AND (`sentry_groupedmessage`.`project_id`) IN (SELECT `sentry_project`.`id` FROM `sentry_project` WHERE (`sentry_project`.`organization_id` = 1 AND (`sentry_project`.`team_id`) IN (SELECT `sentry_organizationmember_teams`.`team_id` FROM `sentry_organizationmember_teams` WHERE `sentry_organizationmember_teams`.`organizationmember_id` = 295 ))) AND `sentry_groupedmessage`.`status` = 0 AND `sentry_project`.`status` = 0 ) ORDER BY `sort_by` DESC LIMIT 6;
+----+-------------+---------------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------+---------+-----------------------------------------------------------+------+----------------------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+---------------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------+---------+-----------------------------------------------------------+------+----------------------------------------------+
| 1 | SIMPLE | sentry_organizationmember_teams | ref | sentry_organization_organizationmember_id_1634015042409685_uniq,sentry_organizationmember_teams_bf01f511,sentry_organizationmember_teams_95e8aaa1 | sentry_organization_organizationmember_id_1634015042409685_uniq | 8 | const | 68 | Using index; Using temporary; Using filesort |
| 1 | SIMPLE | sentry_project | ref | PRIMARY,sentry_project_organization_id_3017a54aeb676236_uniq,sentry_project_95e8aaa1,sentry_project_de772da3 | sentry_project_95e8aaa1 | 8 | sentry_production.sentry_organizationmember_teams.team_id | 3 | Using where |
| 1 | SIMPLE | sentry_project | eq_ref | PRIMARY,sentry_project_48fb58bb | PRIMARY | 8 | sentry_production.sentry_project.id | 1 | Using where |
| 1 | SIMPLE | sentry_groupedmessage | ref | sentry_groupedmessage_48fb58bb,sentry_groupedmessage_37952554,sentry_groupedmessage_47488fba,sentry_groupedmessage_project_id_31ef19bb52cc13be,sentry_groupedmessage_project_id_31335ae34c8ef983 | sentry_groupedmessage_project_id_31335ae34c8ef983 | 9 | sentry_production.sentry_project.id | 1070 | Using where |
+----+-------------+---------------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------+---------+-----------------------------------------------------------+------+----------------------------------------------+
4 rows in set (0.02 sec)
kuzmik:sentry_production> SELECT
-> table_schema as `Database`,
-> table_name AS `Table`,
-> round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB`
-> FROM information_schema.TABLES
-> ORDER BY (data_length + index_length) DESC;
+--------------------+---------------------------------------+------------+
| Database | Table | Size in MB |
+--------------------+---------------------------------------+------------+
| sentry_production | sentry_eventmapping | 127926.70 |
| sentry_production | sentry_messagefiltervalue | 73404.42 |
| sentry_production | sentry_eventtag | 56283.77 |
| sentry_production | sentry_groupedmessage | 39797.06 |
| sentry_production | sentry_message | 37411.81 |
| sentry_production | sentry_grouptagkey | 31848.50 |
| sentry_production | sentry_activity | 7177.55 |
| sentry_production | sentry_grouphash | 6345.53 |
| sentry_production | sentry_grouprulestatus | 4992.23 |
| sentry_production | sentry_filtervalue | 4683.31 |
| sentry_production | sentry_eventuser | 273.84 |
| sentry_production | sentry_groupemailthread | 149.72 |
| sentry_production | sentry_release | 24.11 |
| sentry_production | sentry_groupredirect | 20.50 |
| sentry_production | sentry_useroption | 11.77 |
| sentry_production | sentry_groupseen | 8.94 |
| sentry_production | sentry_auditlogentry | 4.63 |
| sentry_production | sentry_organizationmember_teams | 4.00 |
| sentry_production | sentry_projectoptions | 1.11 |
| sentry_production | sentry_filterkey | 0.77 |
| sentry_production | sentry_savedsearch | 0.47 |
| sentry_production | sentry_rule | 0.44 |
| sentry_production | sentry_project | 0.22 |
| sentry_production | sentry_projectkey | 0.22 |
| sentry_production | sentry_organizationmember | 0.17 |
| sentry_production | sentry_useravatar | 0.14 |
| sentry_production | sentry_groupasignee | 0.09 |
| sentry_production | sentry_groupbookmark | 0.09 |
| sentry_production | sentry_groupmeta | 0.09 |
| sentry_production | auth_user | 0.09 |
| sentry_production | sentry_userreport | 0.09 |
| sentry_production | sentry_authidentity | 0.08 |
| sentry_production | sentry_releasefile | 0.08 |
| sentry_production | sentry_savedsearch_userdefault | 0.08 |
| sentry_production | djkombu_message | 0.06 |
| sentry_production | sentry_authprovider_default_teams | 0.06 |
| sentry_production | sentry_apikey | 0.06 |
| sentry_production | sentry_broadcastseen | 0.06 |
| sentry_production | sentry_apitoken | 0.06 |
| sentry_production | sentry_fileblobindex | 0.06 |
| sentry_production | sentry_dsymsymbol | 0.06 |
| sentry_production | sentry_groupresolution | 0.06 |
| sentry_production | sentry_projectplatform | 0.06 |
| sentry_production | sentry_organizationaccessrequest | 0.06 |
| sentry_production | sentry_projectcounter | 0.06 |
| sentry_production | sentry_projectdsymfile | 0.06 |
| sentry_production | sentry_organizationonboardingtask | 0.06 |
| sentry_production | sentry_dsymbundle | 0.05 |
| sentry_production | sentry_dsymobject | 0.05 |
| sentry_production | sentry_dsymsdk | 0.05 |
| sentry_production | sentry_globaldsymfile | 0.05 |
| sentry_production | sentry_file | 0.05 |
| sentry_production | sentry_fileblob | 0.05 |
| sentry_production | sentry_organizationoptions | 0.05 |
| sentry_production | auth_permission | 0.05 |
| sentry_production | sentry_projectbookmark | 0.05 |
| sentry_production | auth_group_permissions | 0.05 |
| sentry_production | social_auth_association | 0.05 |
| sentry_production | social_auth_nonce | 0.05 |
| sentry_production | social_auth_usersocialauth | 0.05 |
| sentry_production | sentry_team | 0.05 |
| sentry_production | south_migrationhistory | 0.05 |
| sentry_production | djkombu_queue | 0.03 |
| sentry_production | sentry_authprovider | 0.03 |
| sentry_production | nodestore_node | 0.03 |
| sentry_production | sentry_broadcast | 0.03 |
| sentry_production | sentry_groupsnooze | 0.03 |
| sentry_production | sentry_helppage | 0.03 |
| sentry_production | sentry_lostpasswordhash | 0.03 |
| sentry_production | sentry_messageindex | 0.03 |
| sentry_production | sentry_option | 0.03 |
| sentry_production | sentry_organization | 0.03 |
| sentry_production | django_admin_log | 0.03 |
| sentry_production | django_content_type | 0.03 |
| sentry_production | auth_authenticator | 0.03 |
| sentry_production | django_session | 0.03 |
| sentry_production | auth_group | 0.03 |
| sentry_production | django_site | 0.02 |
| slow_query_log | duplicate_indexes | 0.02 |
| slow_query_log | tables_without_pk | 0.02 |
| information_schema | TRIGGERS | 0.00 |
| information_schema | VIEWS | 0.00 |
| information_schema | EVENTS | 0.00 |
| information_schema | COLUMNS | 0.00 |
| information_schema | PARAMETERS | 0.00 |
| information_schema | PARTITIONS | 0.00 |
| information_schema | PLUGINS | 0.00 |
| information_schema | PROCESSLIST | 0.00 |
| information_schema | OPTIMIZER_TRACE | 0.00 |
| information_schema | ROUTINES | 0.00 |
| information_schema | INNODB_CMP | 0.00 |
| information_schema | INNODB_FT_BEING_DELETED | 0.00 |
| information_schema | INNODB_CHANGED_PAGES | 0.00 |
| information_schema | QUERY_RESPONSE_TIME_WRITE | 0.00 |
| information_schema | INNODB_SYS_FOREIGN_COLS | 0.00 |
| information_schema | TABLE_STATISTICS | 0.00 |
| information_schema | QUERY_RESPONSE_TIME_READ | 0.00 |
| information_schema | TEMPORARY_TABLES | 0.00 |
| information_schema | XTRADB_INTERNAL_HASH_TABLES | 0.00 |
| information_schema | THREAD_STATISTICS | 0.00 |
| information_schema | INNODB_SYS_DATAFILES | 0.00 |
| information_schema | XTRADB_RSEG | 0.00 |
| information_schema | TABLESPACES | 0.00 |
| information_schema | USER_PRIVILEGES | 0.00 |
| information_schema | TABLE_CONSTRAINTS | 0.00 |
| information_schema | USER_STATISTICS | 0.00 |
| information_schema | TABLE_PRIVILEGES | 0.00 |
| information_schema | INNODB_CMP_RESET | 0.00 |
| information_schema | INNODB_SYS_INDEXES | 0.00 |
| information_schema | INNODB_CMP_PER_INDEX | 0.00 |
| information_schema | INNODB_SYS_TABLES | 0.00 |
| information_schema | INNODB_LOCKS | 0.00 |
| information_schema | INNODB_SYS_FIELDS | 0.00 |
| information_schema | INNODB_FT_DELETED | 0.00 |
| information_schema | INNODB_BUFFER_PAGE_LRU | 0.00 |
| information_schema | INNODB_SYS_TABLESTATS | 0.00 |
| information_schema | XTRADB_READ_VIEW | 0.00 |
| information_schema | INNODB_TRX | 0.00 |
| information_schema | INNODB_LOCK_WAITS | 0.00 |
| information_schema | SQUARE_IPS | 0.00 |
| information_schema | INNODB_CMPMEM_RESET | 0.00 |
| information_schema | CLIENT_STATISTICS | 0.00 |
| information_schema | COLLATIONS | 0.00 |
| information_schema | FILES | 0.00 |
| information_schema | COLLATION_CHARACTER_SET_APPLICABILITY | 0.00 |
| information_schema | GLOBAL_STATUS | 0.00 |
| information_schema | GLOBAL_TEMPORARY_TABLES | 0.00 |
| information_schema | COLUMN_PRIVILEGES | 0.00 |
| information_schema | GLOBAL_VARIABLES | 0.00 |
| information_schema | INDEX_STATISTICS | 0.00 |
| information_schema | KEY_COLUMN_USAGE | 0.00 |
| information_schema | CHARACTER_SETS | 0.00 |
| information_schema | ENGINES | 0.00 |
| information_schema | SCHEMATA | 0.00 |
| information_schema | QUERY_RESPONSE_TIME | 0.00 |
| information_schema | INNODB_BUFFER_PAGE | 0.00 |
| information_schema | SQUARE_HOST_INFO | 0.00 |
| information_schema | SCHEMA_PRIVILEGES | 0.00 |
| information_schema | INNODB_METRICS | 0.00 |
| information_schema | INNODB_FT_CONFIG | 0.00 |
| information_schema | SESSION_STATUS | 0.00 |
| information_schema | INNODB_BUFFER_POOL_STATS | 0.00 |
| information_schema | INNODB_FT_INDEX_TABLE | 0.00 |
| information_schema | SESSION_VARIABLES | 0.00 |
| information_schema | INNODB_CMPMEM | 0.00 |
| information_schema | PROFILING | 0.00 |
| information_schema | INNODB_CMP_PER_INDEX_RESET | 0.00 |
| information_schema | STATISTICS | 0.00 |
| information_schema | INNODB_SYS_FOREIGN | 0.00 |
| information_schema | REFERENTIAL_CONSTRAINTS | 0.00 |
| information_schema | INNODB_SYS_TABLESPACES | 0.00 |
| information_schema | TABLES | 0.00 |
| information_schema | INNODB_SYS_COLUMNS | 0.00 |
| information_schema | INNODB_FT_INDEX_CACHE | 0.00 |
| information_schema | INNODB_FT_DEFAULT_STOPWORD | 0.00 |
+--------------------+---------------------------------------+------------+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.