[英]Query executes very slow?
I have a table in which there are four column ID,MID,SID and Amt, I prepare the query for count the sum of amt using level.我有一个表,其中有四列 ID、MID、SID 和 Amt,我准备查询以使用 level 计算 amt 的总和。
Like:喜欢:
SELECT Sum(amt) as level1 FROM adm where sid='MT00001';
SELECT Sum(amt) as level2 FROM adm where sid in (SELECT mid FROM adm where sid='MT00001');
SELECT Sum(amt) as level3 FROM adm where sid in (SELECT mid FROM adm where sid in (SELECT mid FROM adm where sid='MT00001'));
SELECT Sum(amt) as level4 FROM adm where sid in (SELECT mid FROM adm where sid in (SELECT mid FROM adm where sid in (SELECT mid FROM adm where sid='MT00001')))
but took so much time and i want this till level 15th但是花了很多时间,我想要这个直到第 15 级
EXPLAIN [your query here]
This will help you understand the current status of your query and tables.这将帮助您了解查询和表的当前状态。
Adding Index on your table will help additional performance on your queries.在表上添加索引将有助于提高查询性能。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.