Search code examples
sqlms-accessquery-performance

MS-Access SQL Query Performance - Slow


I have a query that pulls data and joins from other queries. The final query is taking about 8 minutes to run. Is there a more efficient way to query the information from queries built on queries (such as creating a table with the results of the first queries OR building an index - OR ??).

My final query is as simple as:

SELECT Filtered_ZFEWN.[Base 8], Filtered_ZFEWN.Notification, Filtered_ZFEWN.
[Service Product], Filtered_ZFEWN.[Product Hierarchy]
FROM Filtered_ZFEWN RIGHT JOIN 
    Notifications_by_Base_8 ON Filtered_ZFEWN.[Base 8] = 
    Notifications_by_Base_8.[ZFEWN Base 8]
WHERE Notifications_by_Base_8.[Product Hierarchy] IN 
    (SELECT Notifications_by_Base_8.[Product Hierarchy] 
     FROM Notifications_by_Base_8 
     WHERE Notifications_by_Base_8.[Product Hierarchy] NOT LIKE "*MISC*");

This query is pulling data from 6 other queries (you can see it explicitly pulls from two queries, but the other queries are also built upon 4 queries). I am looking for performance improvement.


Solution

  • Isn't the subquery (query after the IN key word) redundant and always returns the same result? – Peeyush 15 hours ago

    @peeyush You are correct - That is the answer. I removed the select subquery and kept only the NOT LIKE "misc" portion and this ran in 8 seconds. Thank you!!! – Analyst123456789 11 secs ago edit