레코드가 600,000 개 이상인 여러 테이블에서 데이터를 가져옵니다. 그러나 그것을 가져 오는 데는 많은 시간을 필요로합니다. 가져 오는 시간을 단축하는 방법을 알려주세요. LIMIT 사례도 사용했지만 개선은 없습니다.MySQL 쿼리 데이터를 가져 오는 데 많은 시간을 할애합니다.
내 쿼리는 다음과 같습니다
SELECT DISTINCT
tf_history.thefind_id,
tf_product.product_id,
tf_product.`name`,
tf_product.product_url,
tf_product.image_tpm,
tf_product.image_thefind,
tf_product.image_accuracy,
(SELECT MIN(tf_h.price)
FROM tf_history AS tf_h
WHERE tf_h.thefind_id = tf_history.thefind_id) as price,
oc_product.price AS priceTPM
FROM tf_product
LEFT JOIN tf_history ON tf_product.product_id = tf_history.product_id
AND tf_product.thefind_id = tf_history.thefind_id
LEFT JOIN oc_product ON tf_product.product_id = oc_product.product_id
WHERE tf_product.product_id = @product_id
내 테이블 :
tf_history
history_id int(11) NO PRI auto_increment
thefind_id int(11) NO
product_id int(11) NO
price decimal(15,4) NO
date datetime NO
AND
tf_product
thefind_id int(11) NO PRI auto_increment
product_id int(11) NO
name varchar(255) NO
store_id int(11) NO
product_url varchar(255) NO
image_tpm varchar(255) NO
image_thefind varchar(255) NO
image_accuracy int(3) NO
date datetime NO
하지만 난이 쿼리를 사용할 때 :
SELECT * from tf_history
을 내가 0.641s에 결과를 가지고, 그 다음 무엇을 할 수 문제가 되니? 레코드 수가 적 으면 첫 번째 쿼리가 원활하게 실행되고있었습니다.
테이블 정의 란 무엇입니까? 어떤 지표가 있습니까? 어떤 종류의 하드웨어를 실행하고 있습니까? "많은 시간과 많은 시간"은 무엇입니까? 초입니까? 의사록? 시간? –
내 하드웨어가 이중 코어 – Paz
그리고 디스크 입출력 시스템이 플로피 디스크입니까? SATA? RAID? NAS? 데이터 양에 비해 얼마나 많은 메모리가 필요합니까? 이 모든 것들이 중요 할 수 있습니다. –