RogerCooper
Registered User.
- Local time
- Today, 12:22
- Joined
- Jul 30, 2014
- Messages
- 283
I have the following query on external tables
SELECT SYSADM_CUSTOMER_ORDER.ID AS [SO#], SYSADM_CUSTOMER_ORDER.CUSTOMER_PO_REF, SYSADM_CUST_ORDER_LINE.PART_ID, SYSADM_CUST_ORDER_LINE.UNIT_PRICE, SYSADM_CUST_ORDER_LINE.TRADE_DISC_PERCENT, CCur([unit_price]*(100-[Trade_Disc_Percent])/100) AS [Net Price], GCommerce.[Unit Price], Abs(CCur([unit_price]*(100-[Trade_Disc_Percent])/100)-[Unit Price]) AS Discrepancy
FROM (GCommerce INNER JOIN SYSADM_CUSTOMER_ORDER ON GCommerce.PurchaseOrderNumber = SYSADM_CUSTOMER_ORDER.CUSTOMER_PO_REF) INNER JOIN SYSADM_CUST_ORDER_LINE ON (SYSADM_CUSTOMER_ORDER.ID = SYSADM_CUST_ORDER_LINE.CUST_ORDER_ID) AND (GCommerce.[Line Number] = SYSADM_CUST_ORDER_LINE.LINE_NO)
ORDER BY SYSADM_CUSTOMER_ORDER.ID;
SYSADM_CUSTOMER_ORDER & SYSADM_CUST_ORDER_LINE are Oracle Tables, GCommerce is a text table. The query takes a few seconds to run.
If add a criterion to the query:
SELECT SYSADM_CUSTOMER_ORDER.ID AS [SO#], SYSADM_CUSTOMER_ORDER.CUSTOMER_PO_REF, SYSADM_CUST_ORDER_LINE.PART_ID, SYSADM_CUST_ORDER_LINE.UNIT_PRICE, SYSADM_CUST_ORDER_LINE.TRADE_DISC_PERCENT, CCur([unit_price]*(100-[Trade_Disc_Percent])/100) AS [Net Price], GCommerce.[Unit Price], Abs(CCur([unit_price]*(100-[Trade_Disc_Percent])/100)-[Unit Price]) AS Discrepancy
FROM (GCommerce INNER JOIN SYSADM_CUSTOMER_ORDER ON GCommerce.PurchaseOrderNumber = SYSADM_CUSTOMER_ORDER.CUSTOMER_PO_REF) INNER JOIN SYSADM_CUST_ORDER_LINE ON (SYSADM_CUSTOMER_ORDER.ID = SYSADM_CUST_ORDER_LINE.CUST_ORDER_ID) AND (GCommerce.[Line Number] = SYSADM_CUST_ORDER_LINE.LINE_NO)
WHERE (((Abs(CCur([unit_price]*(100-[Trade_Disc_Percent])/100)-[Unit Price]))>0.01))
ORDER BY SYSADM_CUSTOMER_ORDER.ID;
The query slows and eventually fails from using too much memory. I know that I can populate a table as a workaround. However, why is this failing? Is there a way to prevent this?
SELECT SYSADM_CUSTOMER_ORDER.ID AS [SO#], SYSADM_CUSTOMER_ORDER.CUSTOMER_PO_REF, SYSADM_CUST_ORDER_LINE.PART_ID, SYSADM_CUST_ORDER_LINE.UNIT_PRICE, SYSADM_CUST_ORDER_LINE.TRADE_DISC_PERCENT, CCur([unit_price]*(100-[Trade_Disc_Percent])/100) AS [Net Price], GCommerce.[Unit Price], Abs(CCur([unit_price]*(100-[Trade_Disc_Percent])/100)-[Unit Price]) AS Discrepancy
FROM (GCommerce INNER JOIN SYSADM_CUSTOMER_ORDER ON GCommerce.PurchaseOrderNumber = SYSADM_CUSTOMER_ORDER.CUSTOMER_PO_REF) INNER JOIN SYSADM_CUST_ORDER_LINE ON (SYSADM_CUSTOMER_ORDER.ID = SYSADM_CUST_ORDER_LINE.CUST_ORDER_ID) AND (GCommerce.[Line Number] = SYSADM_CUST_ORDER_LINE.LINE_NO)
ORDER BY SYSADM_CUSTOMER_ORDER.ID;
SYSADM_CUSTOMER_ORDER & SYSADM_CUST_ORDER_LINE are Oracle Tables, GCommerce is a text table. The query takes a few seconds to run.
If add a criterion to the query:
SELECT SYSADM_CUSTOMER_ORDER.ID AS [SO#], SYSADM_CUSTOMER_ORDER.CUSTOMER_PO_REF, SYSADM_CUST_ORDER_LINE.PART_ID, SYSADM_CUST_ORDER_LINE.UNIT_PRICE, SYSADM_CUST_ORDER_LINE.TRADE_DISC_PERCENT, CCur([unit_price]*(100-[Trade_Disc_Percent])/100) AS [Net Price], GCommerce.[Unit Price], Abs(CCur([unit_price]*(100-[Trade_Disc_Percent])/100)-[Unit Price]) AS Discrepancy
FROM (GCommerce INNER JOIN SYSADM_CUSTOMER_ORDER ON GCommerce.PurchaseOrderNumber = SYSADM_CUSTOMER_ORDER.CUSTOMER_PO_REF) INNER JOIN SYSADM_CUST_ORDER_LINE ON (SYSADM_CUSTOMER_ORDER.ID = SYSADM_CUST_ORDER_LINE.CUST_ORDER_ID) AND (GCommerce.[Line Number] = SYSADM_CUST_ORDER_LINE.LINE_NO)
WHERE (((Abs(CCur([unit_price]*(100-[Trade_Disc_Percent])/100)-[Unit Price]))>0.01))
ORDER BY SYSADM_CUSTOMER_ORDER.ID;
The query slows and eventually fails from using too much memory. I know that I can populate a table as a workaround. However, why is this failing? Is there a way to prevent this?