Phpmyadmin run very slow
i have made some DB use Phpmyadmin
.I can run it well before, but after i try some complicated query it run very slow.
i must wait about 5 minutes to get the count result. But for the simple query it runs well. Why its happen? Could I solve this problem?
How do i do that?
SELECT X.id,X.Line,X.Model,X.Lot_no,X.Lot_Quantity,
X.Merchandise AS Merchandise,
X.Merchandise-X.Lot_Quantity AS Balance
FROM(
SELECT A.Inspection_datetime,A.id,A.Line, A.Model,
A.Lot_no,B.Lot_Quantity,
IF(RIGHT(A.Range_sampling,4)='0000',10000,
RIGHT(A.Range_sampling,4))-MID(Ra开发者_JAVA百科nge_sampling,5,4)+1
AS Merchandise
FROM inspection_report A
LEFT JOIN prod_sch B
ON A.Line= B.Line_Name AND A.Model = B.Model_Code
AND A.Lot_no= CONCAT(LPAD(CAST(B.Lot_No_ AS CHAR),3,'0'),'A')
WHERE MONTH(A.Inspection_datetime) = MONTH(CURRENT_DATE)
AND YEAR(A.Inspection_datetime) = YEAR(CURRENT_DATE)
GROUP BY A.Line, A.Model,A.Range_sampling) X
GROUP BY X.Model
does your query included multiple join
and many where condition
?? then u must create index on selected attributes which are used in ON
and WHERE
clause.
BTW... show your table structure as well as your Query...then can be give better solution
make index on following attributes in your table
Line,Model,Lot_no,Inspection_datetime,range_sampling( Table : insepection_report) Line_Name,Model_code( Table: prod_sch )
Note:
try with EXPLAIN before SELECT and see the result
If you are running complex queries it is probably the underlying MySQL Database that is causing the delay, not phpMyAdmin. You might want to optimize your queries or database structure.
You needs to create indexes on columns which are used in where clause to find the rows.
Indexes can do the thing fast.
精彩评论