나는 웹 페이지 (wordpress)를 테스트하고 있는데,이 로그를 가지고 있지만 실제로 느린 쿼리가 어떤 것인지 이해할 수 없다. 내 웹 사이트의 쿼리를 읽는 링크는 위험한 쿼리가 무엇인지 말해 줄 시간을 찾아라. 슬로우 쿼리 로그 작업을 사용하여 내 CPU정말 느린 쿼리를 찾는 방법은 무엇입니까?
http://balkanweb.com/mysql_slow.log
나는 웹 페이지 (wordpress)를 테스트하고 있는데,이 로그를 가지고 있지만 실제로 느린 쿼리가 어떤 것인지 이해할 수 없다. 내 웹 사이트의 쿼리를 읽는 링크는 위험한 쿼리가 무엇인지 말해 줄 시간을 찾아라. 슬로우 쿼리 로그 작업을 사용하여 내 CPU정말 느린 쿼리를 찾는 방법은 무엇입니까?
http://balkanweb.com/mysql_slow.log
가장 좋은 무료 도구를 죽이 로그는 PT-쿼리 다이제스트입니다. 기본적으로 쿼리 집계에 의해 집계되는 응답 시간을 보여주는 보고서를 생성합니다.
로그를 다운로드하고 pt-query-digest를 통해 실행했습니다. 다음은 쿼리의 순위 목록은 출력의 일부 그들이 가지고 얼마나 많은 시간에 대한 통계는 다음과 같습니다
# Profile
# Rank Query ID Response time Calls R/Call V/M Item
# ==== ================== ================ ===== ======== ===== ==========
# 1 0xC52F6DEC37D30D44 15065.0357 51.6% 80 188.3129 3.18 SELECT bwp_options
# 2 0x4876D9B1B390C783 4989.7583 17.1% 28 178.2057 7.91 SELECT bwp_options
# 3 0xE6593111E942BBD2 2337.6846 8.0% 10 233.7685 2.10 UPDATE bwp_options
# 4 0xF25CBDE8A6D65826 1784.7358 6.1% 8 223.0920 1.23 SELECT bwp_postmeta
# 5 0xC19DB36FFE85363C 1225.1890 4.2% 5 245.0378 0.09 SELECT bwp_terms bwp_term_taxonomy
# 6 0x7AC4A4CA8054E73D 981.1785 3.4% 4 245.2946 0.10 SELECT bwp_terms bwp_term_taxonomy bwp_term_relationships
# 7 0x3C55C7D48BD1B7C5 714.0035 2.4% 3 238.0012 0.00 SELECT bwp_term_relationships bwp_term_taxonomy
# 8 0x3A5E09EFF2C9AA73 487.4629 1.7% 2 243.7314 0.08 UPDATE bwp_postmeta
# 9 0x6545AED3996807BC 460.0886 1.6% 2 230.0443 0.22 SELECT bwp_postmeta
# 13 0x7AEDF19FDD3A33F1 207.8139 0.7% 30 6.9271 1.11 SELECT wp_options
# MISC 0xMISC 962.7022 3.3% 25 38.5081 0.0 <12 ITEMS>
당신은 # 1 쿼리가 평균 188 초에서 가장 느린 아니라고 볼 수 있지만, 통화 수 (80)는 다른 통화보다 많으므로 가장 많은 응답 시간을 차지합니다.
SELECT option_value FROM bwp_options WHERE option_name = 'ossdl_https' LIMIT 1
나는 당신이 테이블에 option_name
컬럼에 인덱스를 필요로하는 것이 좋습니다 것입니다 : 그 # 1 쿼리는 다음과 같다.
다른 여러 쿼리는 매우 오래 실행되며 평균적으로 178-245 초 사이입니다. 인덱스를 사용하여 이러한 모든 쿼리를 최적화해야합니다. 사실, 서버가 너무 느려서 서버가 부적절한 자원을 가지고 있는지 궁금합니다. 너 교환하고있어? 여기
가 소개 몇 가지 좋은 블로그 게시물입니다 PT-쿼리 소화 :PT-쿼리 다이제스트의 일부입니다 Percona Toolkit은 MySQL 및 Percona Server 작업을위한 무료 오픈 소스 스크립트 도구 모음입니다.
시간 복용 쿼리는이 상위 5 느리게 표시됩니다
Count: 1 Time=2.90s (2s) Lock=0.00s (0s) Rows=1.0 (1), balkanwe_site[balkanwe_site]@localhost
SELECT bwp_posts.* FROM bwp_posts WHERE N=N AND (((bwp_posts.post_title LIKE 'S') OR (bwp_posts.post_content LIKE 'S')) AND ((bwp_posts.post_title LIKE 'S') OR (bwp_posts.post_content LIKE 'S'))) AND (bwp_posts.post_password = 'S') AND bwp_posts.post_type IN ('S', 'S', 'S', 'S', 'S') AND (bwp_posts.post_status = 'S') ORDER BY (CASE WHEN bwp_posts.post_title LIKE 'S' THEN N WHEN bwp_posts.post_title LIKE 'S' AND bwp_posts.post_title LIKE 'S' THEN N WHEN bwp_posts.post_title LIKE 'S' OR bwp_posts.post_title LIKE 'S' THEN N WHEN bwp_posts.post_content LIKE 'S' THEN N ELSE N END), bwp_posts.post_date DESC
Count: 1 Time=2.96s (2s) Lock=0.00s (0s) Rows=1.0 (1), balkanwe_site[balkanwe_site]@localhost
SELECT SQL_CALC_FOUND_ROWS bwp_posts.ID FROM bwp_posts WHERE N=N AND (((bwp_posts.post_title LIKE 'S') OR (bwp_posts.post_content LIKE 'S')) AND ((bwp_posts.post_title LIKE 'S') OR (bwp_posts.post_content LIKE 'S'))) AND (bwp_posts.post_password = 'S') AND bwp_posts.post_type IN ('S', 'S', 'S', 'S', 'S') AND (bwp_posts.post_status = 'S') ORDER BY (CASE WHEN bwp_posts.post_title LIKE 'S' THEN N WHEN bwp_posts.post_title LIKE 'S' AND bwp_posts.post_title LIKE 'S' THEN N WHEN bwp_posts.post_title LIKE 'S' OR bwp_posts.post_title LIKE 'S' THEN N WHEN bwp_posts.post_content LIKE 'S' THEN N ELSE N END), bwp_posts.post_date DESC LIMIT N, N
Count: 2 Time=1.57s (3s) Lock=0.00s (0s) Rows=20.0 (40), balkanwe_wp[balkanwe_wp]@localhost
(SELECT n.IDNotizia, n.Titolo, n.IDCategoria, n.Data, n.Descrizione, N AS Notizia FROM notizie AS n, notizie_legami AS nl WHERE n.IDNotizia=nl.IDNotizia AND n.Online='S' AND (n.Pubblicail='S' OR n.Pubblicail IS NULL) AND (n.Titolo LIKE 'S' OR n.Sottotitolo LIKE 'S' OR n.Descrizione LIKE 'S' OR n.Notizia like 'S') GROUP BY nl.IDCollegamento) UNION (SELECT IDNews, Titolo, IDCategoria, Data, News, N AS Notizia FROM news WHERE id_ext!='S' AND (Titolo LIKE 'S' OR News LIKE 'S')) ORDER BY Data DESC LIMIT N
Count: 1 Time=1.88s (1s) Lock=0.00s (0s) Rows=16.0 (16), root[root]@localhost
SELECT TABLE_SCHEMA as DB,SUM(DATA_LENGTH)+SUM(INDEX_LENGTH) AS SPACEUSED from information_schema.tables GROUP BY TABLE_SCHEMA
Count: 1 Time=1.06s (1s) Lock=0.00s (0s) Rows=20.0 (20), balkanwe_wp[balkanwe_wp]@localhost
(SELECT n.IDNotizia, n.Titolo, n.IDCategoria, n.Data, n.Descrizione, N AS Notizia FROM notizie AS n, notizie_legami AS nl WHERE n.IDNotizia=nl.IDNotizia AND n.Online='S' AND (n.Pubblicail='S' OR n.Pubblicail IS NULL) AND ((n.Titolo LIKE 'S' OR n.Sottotitolo LIKE 'S' OR n.Descrizione LIKE 'S' OR n.Notizia LIKE 'S') AND (n.Titolo LIKE 'S' OR n.Sottotitolo LIKE 'S' OR n.Descrizione LIKE 'S' OR n.Notizia LIKE 'S')) GROUP BY nl.IDCollegamento) UNION (SELECT IDNews, Titolo, IDCategoria, Data, News, N AS Notizia FROM news WHERE id_ext!='S' AND ((Titolo LIKE 'S' OR News LIKE 'S') AND (Titolo LIKE 'S' OR News LIKE 'S'))) ORDER BY Data DESC LIMIT N
Count: 1 Time=1.21s (1s) Lock=0.00s (0s) Rows=34.0 (34), balkanwe_wp[balkanwe_wp]@localhost
SELECT n.IDNotizia FROM notizie AS n, notizie_legami AS nl WHERE n.IDNotizia=nl.IDNotizia AND n.Online='S' AND (n.Pubblicail='S' OR n.Pubblicail IS NULL) AND ((n.Titolo LIKE 'S' OR n.Sottotitolo LIKE 'S' OR n.Descrizione LIKE 'S' OR n.Notizia LIKE 'S') AND (n.Titolo LIKE 'S' OR n.Sottotitolo LIKE 'S' OR n.Descrizione LIKE 'S' OR n.Notizia LIKE 'S')) GROUP BY nl.IDCollegamento
Count: 4 Time=1.82s (7s) Lock=0.01s (0s) Rows=199.8 (799), balkanwe_wp[balkanwe_wp]@localhost
SELECT n.IDNotizia FROM notizie AS n, notizie_legami AS nl WHERE n.IDNotizia=nl.IDNotizia AND n.Online='S' AND (n.Pubblicail='S' OR n.Pubblicail IS NULL) AND (n.Titolo LIKE 'S' OR n.Sottotitolo LIKE 'S' OR n.Descrizione LIKE 'S' OR n.Notizia like 'S') GROUP BY nl.IDCollegamento
Count: 5 Time=1.52s (7s) Lock=0.00s (0s) Rows=19.4 (97), balkanwe_site[balkanwe_site]@localhost
SELECT ID, post_title, post_type, post_status FROM bwp_posts WHERE (post_title REGEXP 'S' OR post_content REGEXP 'S') AND post_type = 'S' AND ID != N AND post_status NOT IN ('S', 'S') ORDER BY post_date DESC LIMIT N
당신은 명령을 실행하여 느린 쿼리를 확인할 수 있습니다
,
mysqldumpslow이 -s -t 5 slow.log이다 검색어.
이 (가) – gpweb
@gpweb이 아닌 경우 질문에 대한 오해가있을 것입니다. 가장 많은 응답 시간에 대해 어떤 쿼리가 책임이 있는지 말했고 리소스에 대한 링크를 제공하여 동일한 보고서를 직접 만들었습니다. 이 답변을 어떻게 향상시킬 수 있습니까? 너 뭐 찾고있어? –
이 문제를 해결하기 위해이 쿼리를 사용하는 PHP 파일에서 수행 할 작업을 설명 할 시간이 있다면 알려주십시오. – gpweb