Skip to content

Commit

Permalink
慢日志管理兼容pt3.0.11
Browse files Browse the repository at this point in the history
  • Loading branch information
hhyo committed Jul 30, 2018
1 parent 5c682e9 commit e3d9ce3
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 94 deletions.
6 changes: 3 additions & 3 deletions sql/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ class Meta:

# SlowQuery
class SlowQuery(models.Model):
checksum = models.BigIntegerField(primary_key=True)
checksum = models.CharField(max_length=32)
fingerprint = models.TextField()
sample = models.TextField()
first_seen = models.DateTimeField(blank=True, null=True)
Expand Down Expand Up @@ -407,7 +407,7 @@ class SlowQueryHistory(models.Model):

class Meta:
managed = False
db_table = 'mysql_slow_query_review_history'
unique_together = ('hostname_max', 'ts_min')
unique_together = ('checksum', 'ts_min', 'ts_max')
index_together = ('hostname_max', 'ts_min')
verbose_name = u'慢日志明细'
verbose_name_plural = u'慢日志明细'
4 changes: 2 additions & 2 deletions sql/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ def slowquery_review_history(request):
# 获取慢查明细数据
slowsql_record_obj = SlowQueryHistory.objects.filter(
hostname_max=(cluster_info.master_host + ':' + str(cluster_info.master_port)),
checksum=int(SQLId),
checksum=SQLId,
ts_min__range=(StartTime, EndTime)
).annotate(ExecutionStartTime=F('ts_min'), # 执行开始时间
DBName=F('db_max'), # 数据库名
Expand All @@ -962,7 +962,7 @@ def slowquery_review_history(request):

slowsql_obj_count = SlowQueryHistory.objects.filter(
hostname_max=(cluster_info.master_host + ':' + str(cluster_info.master_port)),
checksum=int(SQLId),
checksum=SQLId,
ts_min__range=(StartTime, EndTime)
).count()
else:
Expand Down
178 changes: 89 additions & 89 deletions src/script/mysql_slow_query_review.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CREATE TABLE `mysql_slow_query_review` (
`checksum` bigint(20) unsigned NOT NULL,
`checksum` CHAR(32) NOT NULL,
`fingerprint` longtext NOT NULL,
`sample` longtext NOT NULL,
`first_seen` datetime(6) DEFAULT NULL,
Expand All @@ -18,97 +18,97 @@ CREATE TABLE `mysql_slow_query_review_history` (
`client_max` varchar(64) DEFAULT NULL,
`user_max` varchar(64) NOT NULL,
`db_max` varchar(64) DEFAULT NULL,
`checksum` bigint(20) unsigned NOT NULL,
`checksum` CHAR(32) NOT NULL,
`sample` longtext NOT NULL,
`ts_min` datetime(6) NOT NULL,
`ts_max` datetime(6) NOT NULL,
`ts_cnt` double DEFAULT NULL,
`Query_time_sum` double DEFAULT NULL,
`Query_time_min` double DEFAULT NULL,
`Query_time_max` double DEFAULT NULL,
`Query_time_pct_95` double DEFAULT NULL,
`Query_time_stddev` double DEFAULT NULL,
`Query_time_median` double DEFAULT NULL,
`Lock_time_sum` double DEFAULT NULL,
`Lock_time_min` double DEFAULT NULL,
`Lock_time_max` double DEFAULT NULL,
`Lock_time_pct_95` double DEFAULT NULL,
`Lock_time_stddev` double DEFAULT NULL,
`Lock_time_median` double DEFAULT NULL,
`Rows_sent_sum` double DEFAULT NULL,
`Rows_sent_min` double DEFAULT NULL,
`Rows_sent_max` double DEFAULT NULL,
`Rows_sent_pct_95` double DEFAULT NULL,
`Rows_sent_stddev` double DEFAULT NULL,
`Rows_sent_median` double DEFAULT NULL,
`Rows_examined_sum` double DEFAULT NULL,
`Rows_examined_min` double DEFAULT NULL,
`Rows_examined_max` double DEFAULT NULL,
`Rows_examined_pct_95` double DEFAULT NULL,
`Rows_examined_stddev` double DEFAULT NULL,
`Rows_examined_median` double DEFAULT NULL,
`Rows_affected_sum` double DEFAULT NULL,
`Rows_affected_min` double DEFAULT NULL,
`Rows_affected_max` double DEFAULT NULL,
`Rows_affected_pct_95` double DEFAULT NULL,
`Rows_affected_stddev` double DEFAULT NULL,
`Rows_affected_median` double DEFAULT NULL,
`Rows_read_sum` double DEFAULT NULL,
`Rows_read_min` double DEFAULT NULL,
`Rows_read_max` double DEFAULT NULL,
`Rows_read_pct_95` double DEFAULT NULL,
`Rows_read_stddev` double DEFAULT NULL,
`Rows_read_median` double DEFAULT NULL,
`Merge_passes_sum` double DEFAULT NULL,
`Merge_passes_min` double DEFAULT NULL,
`Merge_passes_max` double DEFAULT NULL,
`Merge_passes_pct_95` double DEFAULT NULL,
`Merge_passes_stddev` double DEFAULT NULL,
`Merge_passes_median` double DEFAULT NULL,
`InnoDB_IO_r_ops_min` double DEFAULT NULL,
`InnoDB_IO_r_ops_max` double DEFAULT NULL,
`InnoDB_IO_r_ops_pct_95` double DEFAULT NULL,
`InnoDB_IO_r_ops_stddev` double DEFAULT NULL,
`InnoDB_IO_r_ops_median` double DEFAULT NULL,
`InnoDB_IO_r_bytes_min` double DEFAULT NULL,
`InnoDB_IO_r_bytes_max` double DEFAULT NULL,
`InnoDB_IO_r_bytes_pct_95` double DEFAULT NULL,
`InnoDB_IO_r_bytes_stddev` double DEFAULT NULL,
`InnoDB_IO_r_bytes_median` double DEFAULT NULL,
`InnoDB_IO_r_wait_min` double DEFAULT NULL,
`InnoDB_IO_r_wait_max` double DEFAULT NULL,
`InnoDB_IO_r_wait_pct_95` double DEFAULT NULL,
`InnoDB_IO_r_wait_stddev` double DEFAULT NULL,
`InnoDB_IO_r_wait_median` double DEFAULT NULL,
`InnoDB_rec_lock_wait_min` double DEFAULT NULL,
`InnoDB_rec_lock_wait_max` double DEFAULT NULL,
`InnoDB_rec_lock_wait_pct_95` double DEFAULT NULL,
`InnoDB_rec_lock_wait_stddev` double DEFAULT NULL,
`InnoDB_rec_lock_wait_median` double DEFAULT NULL,
`InnoDB_queue_wait_min` double DEFAULT NULL,
`InnoDB_queue_wait_max` double DEFAULT NULL,
`InnoDB_queue_wait_pct_95` double DEFAULT NULL,
`InnoDB_queue_wait_stddev` double DEFAULT NULL,
`InnoDB_queue_wait_median` double DEFAULT NULL,
`InnoDB_pages_distinct_min` double DEFAULT NULL,
`InnoDB_pages_distinct_max` double DEFAULT NULL,
`InnoDB_pages_distinct_pct_95` double DEFAULT NULL,
`InnoDB_pages_distinct_stddev` double DEFAULT NULL,
`InnoDB_pages_distinct_median` double DEFAULT NULL,
`QC_Hit_cnt` double DEFAULT NULL,
`QC_Hit_sum` double DEFAULT NULL,
`Full_scan_cnt` double DEFAULT NULL,
`Full_scan_sum` double DEFAULT NULL,
`Full_join_cnt` double DEFAULT NULL,
`Full_join_sum` double DEFAULT NULL,
`Tmp_table_cnt` double DEFAULT NULL,
`Tmp_table_sum` double DEFAULT NULL,
`Tmp_table_on_disk_cnt` double DEFAULT NULL,
`Tmp_table_on_disk_sum` double DEFAULT NULL,
`Filesort_cnt` double DEFAULT NULL,
`Filesort_sum` double DEFAULT NULL,
`Filesort_on_disk_cnt` double DEFAULT NULL,
`Filesort_on_disk_sum` double DEFAULT NULL,
`ts_cnt` float DEFAULT NULL,
`Query_time_sum` float DEFAULT NULL,
`Query_time_min` float DEFAULT NULL,
`Query_time_max` float DEFAULT NULL,
`Query_time_pct_95` float DEFAULT NULL,
`Query_time_stddev` float DEFAULT NULL,
`Query_time_median` float DEFAULT NULL,
`Lock_time_sum` float DEFAULT NULL,
`Lock_time_min` float DEFAULT NULL,
`Lock_time_max` float DEFAULT NULL,
`Lock_time_pct_95` float DEFAULT NULL,
`Lock_time_stddev` float DEFAULT NULL,
`Lock_time_median` float DEFAULT NULL,
`Rows_sent_sum` float DEFAULT NULL,
`Rows_sent_min` float DEFAULT NULL,
`Rows_sent_max` float DEFAULT NULL,
`Rows_sent_pct_95` float DEFAULT NULL,
`Rows_sent_stddev` float DEFAULT NULL,
`Rows_sent_median` float DEFAULT NULL,
`Rows_examined_sum` float DEFAULT NULL,
`Rows_examined_min` float DEFAULT NULL,
`Rows_examined_max` float DEFAULT NULL,
`Rows_examined_pct_95` float DEFAULT NULL,
`Rows_examined_stddev` float DEFAULT NULL,
`Rows_examined_median` float DEFAULT NULL,
`Rows_affected_sum` float DEFAULT NULL,
`Rows_affected_min` float DEFAULT NULL,
`Rows_affected_max` float DEFAULT NULL,
`Rows_affected_pct_95` float DEFAULT NULL,
`Rows_affected_stddev` float DEFAULT NULL,
`Rows_affected_median` float DEFAULT NULL,
`Rows_read_sum` float DEFAULT NULL,
`Rows_read_min` float DEFAULT NULL,
`Rows_read_max` float DEFAULT NULL,
`Rows_read_pct_95` float DEFAULT NULL,
`Rows_read_stddev` float DEFAULT NULL,
`Rows_read_median` float DEFAULT NULL,
`Merge_passes_sum` float DEFAULT NULL,
`Merge_passes_min` float DEFAULT NULL,
`Merge_passes_max` float DEFAULT NULL,
`Merge_passes_pct_95` float DEFAULT NULL,
`Merge_passes_stddev` float DEFAULT NULL,
`Merge_passes_median` float DEFAULT NULL,
`InnoDB_IO_r_ops_min` float DEFAULT NULL,
`InnoDB_IO_r_ops_max` float DEFAULT NULL,
`InnoDB_IO_r_ops_pct_95` float DEFAULT NULL,
`InnoDB_IO_r_ops_stddev` float DEFAULT NULL,
`InnoDB_IO_r_ops_median` float DEFAULT NULL,
`InnoDB_IO_r_bytes_min` float DEFAULT NULL,
`InnoDB_IO_r_bytes_max` float DEFAULT NULL,
`InnoDB_IO_r_bytes_pct_95` float DEFAULT NULL,
`InnoDB_IO_r_bytes_stddev` float DEFAULT NULL,
`InnoDB_IO_r_bytes_median` float DEFAULT NULL,
`InnoDB_IO_r_wait_min` float DEFAULT NULL,
`InnoDB_IO_r_wait_max` float DEFAULT NULL,
`InnoDB_IO_r_wait_pct_95` float DEFAULT NULL,
`InnoDB_IO_r_wait_stddev` float DEFAULT NULL,
`InnoDB_IO_r_wait_median` float DEFAULT NULL,
`InnoDB_rec_lock_wait_min` float DEFAULT NULL,
`InnoDB_rec_lock_wait_max` float DEFAULT NULL,
`InnoDB_rec_lock_wait_pct_95` float DEFAULT NULL,
`InnoDB_rec_lock_wait_stddev` float DEFAULT NULL,
`InnoDB_rec_lock_wait_median` float DEFAULT NULL,
`InnoDB_queue_wait_min` float DEFAULT NULL,
`InnoDB_queue_wait_max` float DEFAULT NULL,
`InnoDB_queue_wait_pct_95` float DEFAULT NULL,
`InnoDB_queue_wait_stddev` float DEFAULT NULL,
`InnoDB_queue_wait_median` float DEFAULT NULL,
`InnoDB_pages_distinct_min` float DEFAULT NULL,
`InnoDB_pages_distinct_max` float DEFAULT NULL,
`InnoDB_pages_distinct_pct_95` float DEFAULT NULL,
`InnoDB_pages_distinct_stddev` float DEFAULT NULL,
`InnoDB_pages_distinct_median` float DEFAULT NULL,
`QC_Hit_cnt` float DEFAULT NULL,
`QC_Hit_sum` float DEFAULT NULL,
`Full_scan_cnt` float DEFAULT NULL,
`Full_scan_sum` float DEFAULT NULL,
`Full_join_cnt` float DEFAULT NULL,
`Full_join_sum` float DEFAULT NULL,
`Tmp_table_cnt` float DEFAULT NULL,
`Tmp_table_sum` float DEFAULT NULL,
`Tmp_table_on_disk_cnt` float DEFAULT NULL,
`Tmp_table_on_disk_sum` float DEFAULT NULL,
`Filesort_cnt` float DEFAULT NULL,
`Filesort_sum` float DEFAULT NULL,
`Filesort_on_disk_cnt` float DEFAULT NULL,
`Filesort_on_disk_sum` float DEFAULT NULL,
`Bytes_sum` float DEFAULT NULL,
`Bytes_min` float DEFAULT NULL,
`Bytes_max` float DEFAULT NULL,
Expand Down

0 comments on commit e3d9ce3

Please sign in to comment.