현재 일부 최적화가 필요한 웹 사이트에서 작업 중입니다 ... 프론트 페이지가로드되는 데 약 15-20 초가 걸리기 때문에 몇 가지 최적화가 좋을 것이라고 생각했습니다. 또한 id
가 기본 키가 perso_id
이 - (이메일 및 프로파일이 포함되어 ~ 207K 라인) profil_perso
에MySQL 쿼리 최적화
SELECT a.user,a.id
FROM `profil_perso` pp
INNER JOIN `acces` a ON pp.parrain = a.id
INNER JOIN `acces` ap ON ap.id = pp.id
WHERE pp.parrain_visibilite = '1'
AND a.actif = 1
GROUP BY a.id
ORDER BY ap.depuis DESC LIMIT 15;
: 여기
는 MySQL의 느린 쿼리 로그에 출연 한 쿼리입니다 (foreign key) +parrain
(referer) +
parrain_visibilite
(referer is shown)이 인덱스입니다.
처음 : 1.94532990456
마지막 시간 : 1.94532990456 acces
에
는
벤치 마크 색인 (등록 날짜)가 실제로 보여줍니다 또한 depuis, 기본 키는 그 id
있다
평균 시간 :
나는 시도는 이런 식으로 넣어 아직 691,363,210
SELECT DISTINCT a.id, a.user
FROM `profil_perso` pp
LEFT JOIN `acces` a ON pp.parrain = a.id
WHERE pp.parrain_visibilite = 1
AND a.actif = 1
AND pp.id != 0
ORDER BY pp.id DESC LIMIT 15;
벤치 마크 공연이 :
처음 : 1.96376991272
마지막 시간 : 1.96376991272
평균 시간 : 0.0393264245987
쿼리 시간을 낮추기 위해 어떤 힌트?
여기 전체 인덱스 :
대한 액세스 :
id (primary)
derniere_visite -- last visit
pays_id -- country_id
depuis -- registration time
perso_id -- foreign key to profil_perso primary key
actif -- account status
compte_premium -- if account is premium
profil_perso :
perso_id (primary)
id -- foreign key to acces primary key
genre -- gender
parrain_visibilite -- visibility of referer
parrain -- referer
parrain_contexte
telephone
orientation
naissance -- birthdate
photo -- if it has a picture
3 개의 테이블에 전체 색인을 게시 할 수 있습니까? 문제에 관해서는 내 최선의 추측이지만 확실하게보아야 할 것입니다. – MBCook
이 모든 것들은 acces.id, acces.ap acces.parrain indexed입니까? – THEn
출력을 원하는대로 설명 할 수 있다면 도움이 될 것입니다. – Greg