简体   繁体   中英

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.

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM