Access Query Running Forever Help???

Mac1206

Board Regular
Joined
Jun 3, 2016
Messages
184
This query runs forever, can this be written better to in order to get a faster result, see below...

SELECT Calculation_Strategy_Price_Tbl.Product_Family, Calculation_Strategy_Price_Tbl.Product_SubFamily, Calculation_Strategy_Price_Tbl.Shape, Calculation_Strategy_Price_Tbl.Size, Calculation_Strategy_Price_Tbl.Ship_to_City, Calculation_Strategy_Price_Tbl.Ship_to_State, Min(Freight_GNAPS_Norm_Transactions_Tbl.Rate) AS MinOfRate
FROM Freight_GNAPS_Norm_Transactions_Tbl INNER JOIN ((List_Price_GNAPS_Tbl INNER JOIN Xref_Shape_Tbl ON List_Price_GNAPS_Tbl.Shape = Xref_Shape_Tbl.GNAPS_SHAPE_ID) INNER JOIN Calculation_Strategy_Price_Tbl ON (Xref_Shape_Tbl.Shape = Calculation_Strategy_Price_Tbl.Shape) AND (List_Price_GNAPS_Tbl.Size = Calculation_Strategy_Price_Tbl.Size)) ON (Freight_GNAPS_Norm_Transactions_Tbl.Ship_to_State = Calculation_Strategy_Price_Tbl.Ship_to_State) AND (Freight_GNAPS_Norm_Transactions_Tbl.City_Dest = Calculation_Strategy_Price_Tbl.Ship_to_City) AND (Freight_GNAPS_Norm_Transactions_Tbl.GNAPS_List_Price = List_Price_GNAPS_Tbl.Plant)
GROUP BY Calculation_Strategy_Price_Tbl.Product_Family, Calculation_Strategy_Price_Tbl.Product_SubFamily, Calculation_Strategy_Price_Tbl.Shape, Calculation_Strategy_Price_Tbl.Size, Calculation_Strategy_Price_Tbl.Ship_to_City, Calculation_Strategy_Price_Tbl.Ship_to_State
HAVING (((Calculation_Strategy_Price_Tbl.Product_Family)="BEAMS") AND ((Calculation_Strategy_Price_Tbl.Product_SubFamily)="WIDE FLANGE BEAMS"));
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
This is very difficult to answer without knowing the structure of your database (including tables and relationships), what your data looks like, and what it is you are trying to accomplish.

Since we do not have any of that information, all I can offer is this. Make sure that all the fields you are joining on are Indexed, and that every table has a Primary Key.
 
Upvote 0
This is very difficult to answer without knowing the structure of your database (including tables and relationships), what your data looks like, and what it is you are trying to accomplish.

Since we do not have any of that information, all I can offer is this. Make sure that all the fields you are joining on are Indexed, and that every table has a Primary Key.
In viewing this query, could you give me an example of one of the fields to index on Joe...Thanks
 
Upvote 0
All the fields listed in your JOIN clauses...
INNER JOIN ((List_Price_GNAPS_Tbl INNER JOIN Xref_Shape_Tbl ON List_Price_GNAPS_Tbl.Shape = Xref_Shape_Tbl.GNAPS_SHAPE_ID) INNER JOIN Calculation_Strategy_Price_Tbl ON (Xref_Shape_Tbl.Shape = Calculation_Strategy_Price_Tbl.Shape) AND (List_Price_GNAPS_Tbl.Size = Calculation_Strategy_Price_Tbl.Size)) ON (Freight_GNAPS_Norm_Transactions_Tbl.Ship_to_State = Calculation_Strategy_Price_Tbl.Ship_to_State) AND (Freight_GNAPS_Norm_Transactions_Tbl.City_Dest = Calculation_Strategy_Price_Tbl.Ship_to_City) AND (Freight_GNAPS_Norm_Transactions_Tbl.GNAPS_List_Price = List_Price_GNAPS_Tbl.Plant)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,221,692
Messages
6,161,351
Members
451,697
Latest member
pedroDH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top