cancel
Showing results for 
Search instead for 
Did you mean: 

If we added a filter, shouldn't the select query run faster?

yalcin_mete
Participant
0 Kudos

Hi Master,

When I run it with only the production plant(werks), the select query runs in a shorter time than when I run it with the production location and material.
How is this possible? Shouldn't the select query run faster when I add material?

yalcin_mete_1-1713339742502.png

yalcin_mete_0-1713339699342.png

 

Thanks.



Tomas_Buryanek
Active Contributor
0 Kudos
Try ST05 and "Explain" (https://community.sap.com/t5/application-development-blog-posts/the-sql-trace-st05-quick-and-easy/ba...). Select Execution plan is most likely confused. You have quite many joins, conditions etc. so it might behave strange. Also check indexes.

Accepted Solutions (1)

Accepted Solutions (1)

yalcin_mete
Participant
0 Kudos

 

I solved the problem.
This problem occurred because I used "SELECT DISTINCT" and "GROUP BY" together.
The problem was solved when I removed "DISTINCT" and continued with "GROUP BY".

SELECT DISTINCT and GROUP BY do almost the same job, so let's not use them both in the same "select" 🙂

Answers (2)

Answers (2)

yalcin_mete
Participant
0 Kudos

I solved the problem.
This problem occurred because I used "SELECT DISTINCT" and "GROUP BY" together.
The problem was solved when I removed "DISTINCT" and continued with "GROUP BY".

SELECT DISTINCT and GROUP BY do almost the same job, so let's not use them both in the same "select" 🙂

thomas_mller13
Participant
0 Kudos

Only, if there is an index on these fields. Otherwise a full table scan is done.