{"action":"created","comment":{"url":"https://api.github.com/repos/prometheus/mysqld_exporter/pulls/comments/48031470","id":48031470,"diff_hunk":"@@ -1643,6 +1666,33 @@ func scrapeTableSchema(db *sql.DB, ch chan<- prometheus.Metric) error {\n \t}\n \n \tfor _, database := range dbList {\n+\t\tif _, ok := tableSchemaLastRun[database]; !ok {\n+\t\t\ttableSchemaLastRun[database] = time.Time{}\n+\t\t}\n+\t\trandom := rand.Float64() * 0.25\n+\t\tnextRun := *tableSchemaAutoAnalyzeDuration + time.Duration(float64(*tableSchemaAutoAnalyzeDuration)*random)\n+\t\tif *tableSchemaAutoAnalyze && time.Since(tableSchemaLastRun[database]) > nextRun {","path":"mysqld_exporter.go","position":60,"original_position":60,"commit_id":"51a25a0d145822712b2b3b6c79126ef9b0624495","original_commit_id":"51a25a0d145822712b2b3b6c79126ef9b0624495","user":{"login":"beorn7","id":5609886,"avatar_url":"https://avatars.githubusercontent.com/u/5609886?v=3","gravatar_id":"","url":"https://api.github.com/users/beorn7","html_url":"https://github.com/beorn7","followers_url":"https://api.github.com/users/beorn7/followers","following_url":"https://api.github.com/users/beorn7/following{/other_user}","gists_url":"https://api.github.com/users/beorn7/gists{/gist_id}","starred_url":"https://api.github.com/users/beorn7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/beorn7/subscriptions","organizations_url":"https://api.github.com/users/beorn7/orgs","repos_url":"https://api.github.com/users/beorn7/repos","events_url":"https://api.github.com/users/beorn7/events{/privacy}","received_events_url":"https://api.github.com/users/beorn7/received_events","type":"User","site_admin":false},"body":"What @fabxc meant above (in case that isn't clear anyway): This line will work just fine because for unknown databases, the zero value of time.Time is returned (which is very far in the past), so the analyze will be run on new databases (which, actually, with what you are doing above, it will only run 5min later...)","created_at":"2015-12-18T14:51:21Z","updated_at":"2015-12-18T14:51:21Z","html_url":"https://github.com/prometheus/mysqld_exporter/pull/54#discussion_r48031470","pull_request_url":"https://api.github.com/repos/prometheus/mysqld_exporter/pulls/54","_links":{"self":{"href":"https://api.github.com/repos/prometheus/mysqld_exporter/pulls/comments/48031470"},"html":{"href":"https://github.com/prometheus/mysqld_exporter/pull/54#discussion_r48031470"},"pull_request":{"href":"https://api.github.com/repos/prometheus/mysqld_exporter/pulls/54"}}},"pull_request":{"url":"https://api.github.com/repos/prometheus/mysqld_exporter/pulls/54","id":50382129,"html_url":"https://github.com/prometheus/mysqld_exporter/pull/54","diff_url":"https://github.com/prometheus/mysqld_exporter/pull/54.diff","patch_url":"https://github.com/prometheus/mysqld_exporter/pull/54.patch","issue_url":"https://api.github.com/repos/prometheus/mysqld_exporter/issues/54","number":54,"state":"open","locked":false,"title":"Add option to automatic ANALYZE TABLE","user":{"login":"SuperQ","id":1320667,"avatar_url":"https://avatars.githubusercontent.com/u/1320667?v=3","gravatar_id":"","url":"https://api.github.com/users/SuperQ","html_url":"https://github.com/SuperQ","followers_url":"https://api.github.com/users/SuperQ/followers","following_url":"https://api.github.com/users/SuperQ/following{/other_user}","gists_url":"https://api.github.com/users/SuperQ/gists{/gist_id}","starred_url":"https://api.github.com/users/SuperQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SuperQ/subscriptions","organizations_url":"https://api.github.com/users/SuperQ/orgs","repos_url":"https://api.github.com/users/SuperQ/repos","events_url":"https://api.github.com/users/SuperQ/events{/privacy}","received_events_url":"https://api.github.com/users/SuperQ/received_events","type":"User","site_admin":false},"body":"MySQL >= 5.6 does not automatically update table statistics due to\r\nperformance impact.\r\n\r\nThis allows the mysqld_exporter scrapes to trigger stats updates on\r\ndemand.  This could have a load impact on MySQL so best to use in an\r\nout-of-band MySQL server.  For example a hot-backup slave.","created_at":"2015-11-11T13:17:48Z","updated_at":"2015-12-18T14:51:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c65326d6ada11d738dab417924a0d5003436b1f0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/prometheus/mysqld_exporter/pulls/54/commits","review_comments_url":"https://api.github.com/repos/prometheus/mysqld_exporter/pulls/54/comments","review_comment_url":"https://api.github.com/repos/prometheus/mysqld_exporter/pulls/comments{/number}","comments_url":"https://api.github.com/repos/prometheus/mysqld_exporter/issues/54/comments","statuses_url":"https://api.github.com/repos/prometheus/mysqld_exporter/statuses/51a25a0d145822712b2b3b6c79126ef9b0624495","head":{"label":"prometheus:bjk/analyze_table","ref":"bjk/analyze_table","sha":"51a25a0d145822712b2b3b6c79126ef9b0624495","user":{"login":"prometheus","id":3380462,"avatar_url":"https://avatars.githubusercontent.com/u/3380462?v=3","gravatar_id":"","url":"https://api.github.com/users/prometheus","html_url":"https://github.com/prometheus","followers_url":"https://api.github.com/users/prometheus/followers","following_url":"https://api.github.com/users/prometheus/following{/other_user}","gists_url":"https://api.github.com/users/prometheus/gists{/gist_id}","starred_url":"https://api.github.com/users/prometheus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prometheus/subscriptions","organizations_url":"https://api.github.com/users/prometheus/orgs","repos_url":"https://api.github.com/users/prometheus/repos","events_url":"https://api.github.com/users/prometheus/events{/privacy}","received_events_url":"https://api.github.com/users/prometheus/received_events","type":"Organization","site_admin":false},"repo":{"id":32075541,"name":"mysqld_exporter","full_name":"prometheus/mysqld_exporter","owner":{"login":"prometheus","id":3380462,"avatar_url":"https://avatars.githubusercontent.com/u/3380462?v=3","gravatar_id":"","url":"https://api.github.com/users/prometheus","html_url":"https://github.com/prometheus","followers_url":"https://api.github.com/users/prometheus/followers","following_url":"https://api.github.com/users/prometheus/following{/other_user}","gists_url":"https://api.github.com/users/prometheus/gists{/gist_id}","starred_url":"https://api.github.com/users/prometheus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prometheus/subscriptions","organizations_url":"https://api.github.com/users/prometheus/orgs","repos_url":"https://api.github.com/users/prometheus/repos","events_url":"https://api.github.com/users/prometheus/events{/privacy}","received_events_url":"https://api.github.com/users/prometheus/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/prometheus/mysqld_exporter","description":"Exporter for MySQL server metrics","fork":false,"url":"https://api.github.com/repos/prometheus/mysqld_exporter","forks_url":"https://api.github.com/repos/prometheus/mysqld_exporter/forks","keys_url":"https://api.github.com/repos/prometheus/mysqld_exporter/keys{/key_id}","collaborators_url":"https://api.github.com/repos/prometheus/mysqld_exporter/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/prometheus/mysqld_exporter/teams","hooks_url":"https://api.github.com/repos/prometheus/mysqld_exporter/hooks","issue_events_url":"https://api.github.com/repos/prometheus/mysqld_exporter/issues/events{/number}","events_url":"https://api.github.com/repos/prometheus/mysqld_exporter/events","assignees_url":"https://api.github.com/repos/prometheus/mysqld_exporter/assignees{/user}","branches_url":"https://api.github.com/repos/prometheus/mysqld_exporter/branches{/branch}","tags_url":"https://api.github.com/repos/prometheus/mysqld_exporter/tags","blobs_url":"https://api.github.com/repos/prometheus/mysqld_exporter/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/prometheus/mysqld_exporter/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/prometheus/mysqld_exporter/git/refs{/sha}","trees_url":"https://api.github.com/repos/prometheus/mysqld_exporter/git/trees{/sha}","statuses_url":"https://api.github.com/repos/prometheus/mysqld_exporter/statuses/{sha}","languages_url":"https://api.github.com/repos/prometheus/mysqld_exporter/languages","stargazers_url":"https://api.github.com/repos/prometheus/mysqld_exporter/stargazers","contributors_url":"https://api.github.com/repos/prometheus/mysqld_exporter/contributors","subscribers_url":"https://api.github.com/repos/prometheus/mysqld_exporter/subscribers","subscription_url":"https://api.github.com/repos/prometheus/mysqld_exporter/subscription","commits_url":"https://api.github.com/repos/prometheus/mysqld_exporter/commits{/sha}","git_commits_url":"https://api.github.com/repos/prometheus/mysqld_exporter/git/commits{/sha}","comments_url":"https://api.github.com/repos/prometheus/mysqld_exporter/comments{/number}","issue_comment_url":"https://api.github.com/repos/prometheus/mysqld_exporter/issues/comments{/number}","contents_url":"https://api.github.com/repos/prometheus/mysqld_exporter/contents/{+path}","compare_url":"https://api.github.com/repos/prometheus/mysqld_exporter/compare/{base}...{head}","merges_url":"https://api.github.com/repos/prometheus/mysqld_exporter/merges","archive_url":"https://api.github.com/repos/prometheus/mysqld_exporter/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/prometheus/mysqld_exporter/downloads","issues_url":"https://api.github.com/repos/prometheus/mysqld_exporter/issues{/number}","pulls_url":"https://api.github.com/repos/prometheus/mysqld_exporter/pulls{/number}","milestones_url":"https://api.github.com/repos/prometheus/mysqld_exporter/milestones{/number}","notifications_url":"https://api.github.com/repos/prometheus/mysqld_exporter/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/prometheus/mysqld_exporter/labels{/name}","releases_url":"https://api.github.com/repos/prometheus/mysqld_exporter/releases{/id}","created_at":"2015-03-12T12:23:48Z","updated_at":"2015-12-09T22:17:18Z","pushed_at":"2015-12-17T13:14:02Z","git_url":"git://github.com/prometheus/mysqld_exporter.git","ssh_url":"git@github.com:prometheus/mysqld_exporter.git","clone_url":"https://github.com/prometheus/mysqld_exporter.git","svn_url":"https://github.com/prometheus/mysqld_exporter","homepage":"http://prometheus.io/","size":157,"stargazers_count":21,"watchers_count":21,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":12,"mirror_url":null,"open_issues_count":3,"forks":12,"open_issues":3,"watchers":21,"default_branch":"master"}},"base":{"label":"prometheus:master","ref":"master","sha":"087d32a164ed70c00f067fcc8f32f86106487865","user":{"login":"prometheus","id":3380462,"avatar_url":"https://avatars.githubusercontent.com/u/3380462?v=3","gravatar_id":"","url":"https://api.github.com/users/prometheus","html_url":"https://github.com/prometheus","followers_url":"https://api.github.com/users/prometheus/followers","following_url":"https://api.github.com/users/prometheus/following{/other_user}","gists_url":"https://api.github.com/users/prometheus/gists{/gist_id}","starred_url":"https://api.github.com/users/prometheus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prometheus/subscriptions","organizations_url":"https://api.github.com/users/prometheus/orgs","repos_url":"https://api.github.com/users/prometheus/repos","events_url":"https://api.github.com/users/prometheus/events{/privacy}","received_events_url":"https://api.github.com/users/prometheus/received_events","type":"Organization","site_admin":false},"repo":{"id":32075541,"name":"mysqld_exporter","full_name":"prometheus/mysqld_exporter","owner":{"login":"prometheus","id":3380462,"avatar_url":"https://avatars.githubusercontent.com/u/3380462?v=3","gravatar_id":"","url":"https://api.github.com/users/prometheus","html_url":"https://github.com/prometheus","followers_url":"https://api.github.com/users/prometheus/followers","following_url":"https://api.github.com/users/prometheus/following{/other_user}","gists_url":"https://api.github.com/users/prometheus/gists{/gist_id}","starred_url":"https://api.github.com/users/prometheus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prometheus/subscriptions","organizations_url":"https://api.github.com/users/prometheus/orgs","repos_url":"https://api.github.com/users/prometheus/repos","events_url":"https://api.github.com/users/prometheus/events{/privacy}","received_events_url":"https://api.github.com/users/prometheus/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/prometheus/mysqld_exporter","description":"Exporter for MySQL server metrics","fork":false,"url":"https://api.github.com/repos/prometheus/mysqld_exporter","forks_url":"https://api.github.com/repos/prometheus/mysqld_exporter/forks","keys_url":"https://api.github.com/repos/prometheus/mysqld_exporter/keys{/key_id}","collaborators_url":"https://api.github.com/repos/prometheus/mysqld_exporter/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/prometheus/mysqld_exporter/teams","hooks_url":"https://api.github.com/repos/prometheus/mysqld_exporter/hooks","issue_events_url":"https://api.github.com/repos/prometheus/mysqld_exporter/issues/events{/number}","events_url":"https://api.github.com/repos/prometheus/mysqld_exporter/events","assignees_url":"https://api.github.com/repos/prometheus/mysqld_exporter/assignees{/user}","branches_url":"https://api.github.com/repos/prometheus/mysqld_exporter/branches{/branch}","tags_url":"https://api.github.com/repos/prometheus/mysqld_exporter/tags","blobs_url":"https://api.github.com/repos/prometheus/mysqld_exporter/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/prometheus/mysqld_exporter/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/prometheus/mysqld_exporter/git/refs{/sha}","trees_url":"https://api.github.com/repos/prometheus/mysqld_exporter/git/trees{/sha}","statuses_url":"https://api.github.com/repos/prometheus/mysqld_exporter/statuses/{sha}","languages_url":"https://api.github.com/repos/prometheus/mysqld_exporter/languages","stargazers_url":"https://api.github.com/repos/prometheus/mysqld_exporter/stargazers","contributors_url":"https://api.github.com/repos/prometheus/mysqld_exporter/contributors","subscribers_url":"https://api.github.com/repos/prometheus/mysqld_exporter/subscribers","subscription_url":"https://api.github.com/repos/prometheus/mysqld_exporter/subscription","commits_url":"https://api.github.com/repos/prometheus/mysqld_exporter/commits{/sha}","git_commits_url":"https://api.github.com/repos/prometheus/mysqld_exporter/git/commits{/sha}","comments_url":"https://api.github.com/repos/prometheus/mysqld_exporter/comments{/number}","issue_comment_url":"https://api.github.com/repos/prometheus/mysqld_exporter/issues/comments{/number}","contents_url":"https://api.github.com/repos/prometheus/mysqld_exporter/contents/{+path}","compare_url":"https://api.github.com/repos/prometheus/mysqld_exporter/compare/{base}...{head}","merges_url":"https://api.github.com/repos/prometheus/mysqld_exporter/merges","archive_url":"https://api.github.com/repos/prometheus/mysqld_exporter/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/prometheus/mysqld_exporter/downloads","issues_url":"https://api.github.com/repos/prometheus/mysqld_exporter/issues{/number}","pulls_url":"https://api.github.com/repos/prometheus/mysqld_exporter/pulls{/number}","milestones_url":"https://api.github.com/repos/prometheus/mysqld_exporter/milestones{/number}","notifications_url":"https://api.github.com/repos/prometheus/mysqld_exporter/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/prometheus/mysqld_exporter/labels{/name}","releases_url":"https://api.github.com/repos/prometheus/mysqld_exporter/releases{/id}","created_at":"2015-03-12T12:23:48Z","updated_at":"2015-12-09T22:17:18Z","pushed_at":"2015-12-17T13:14:02Z","git_url":"git://github.com/prometheus/mysqld_exporter.git","ssh_url":"git@github.com:prometheus/mysqld_exporter.git","clone_url":"https://github.com/prometheus/mysqld_exporter.git","svn_url":"https://github.com/prometheus/mysqld_exporter","homepage":"http://prometheus.io/","size":157,"stargazers_count":21,"watchers_count":21,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":12,"mirror_url":null,"open_issues_count":3,"forks":12,"open_issues":3,"watchers":21,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/prometheus/mysqld_exporter/pulls/54"},"html":{"href":"https://github.com/prometheus/mysqld_exporter/pull/54"},"issue":{"href":"https://api.github.com/repos/prometheus/mysqld_exporter/issues/54"},"comments":{"href":"https://api.github.com/repos/prometheus/mysqld_exporter/issues/54/comments"},"review_comments":{"href":"https://api.github.com/repos/prometheus/mysqld_exporter/pulls/54/comments"},"review_comment":{"href":"https://api.github.com/repos/prometheus/mysqld_exporter/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/prometheus/mysqld_exporter/pulls/54/commits"},"statuses":{"href":"https://api.github.com/repos/prometheus/mysqld_exporter/statuses/51a25a0d145822712b2b3b6c79126ef9b0624495"}}}}