有没有办法在SQL中解析Parallel from Serial?

时间:2014-07-24 22:55:22

标签: sql oracle parallel-processing

我遇到的问题是我写过的,我们使用的数据仓库不想接受查询,因为它包含一个与Serial或S-> P并行的部分。当我运行解释计划时,它给了我一个微不足道的错误,但是当我运行查询时它出错了。任何想法都会有所帮助。

查询

SELECT /*+ use_hash (doi,seg) */
doi.ORDER_ID AS "PO"
, doi.DISTRIBUTOR_ID AS "Vendor ID"
, doi.ISBN AS "ASIN"
, doi.QUANTITY_ORDERED AS "Quantity Confirmed"
FROM D_DISTRIBUTOR_ORDER_ITEMS doi
JOIN    (SELECT /*+ use_hash */
    psm.ASIN
    FROM PRODUCT_SEGMENT_MEMBERSHIP psm
    WHERE psm.SEGMENT_ID = 784885) seg
ON doi.ISBN = seg.ASIN
WHERE doi.ORDER_DAY = '2009/04/06'
ORDER BY seg.ASIN

3 个答案:

答案 0 :(得分:0)

这应该与您的查询相同。

SELECT 
doi.ORDER_ID AS "PO"
, doi.DISTRIBUTOR_ID AS "Vendor ID"
, doi.ISBN AS "ASIN"
, doi.QUANTITY_ORDERED AS "Quantity Confirmed"
FROM D_DISTRIBUTOR_ORDER_ITEMS doi
JOIN PRODUCT_SEGMENT_MEMBERSHIP psm ON doi.ISBN = psm.ASIN AND psm.SEGMENT_ID = 784885
WHERE doi.ORDER_DAY = '2009/04/06'
ORDER BY psm.ASIN

这是否也会给您一个错误?

答案 1 :(得分:0)

如果您尝试将subquery直接转换为JOIN

,请尝试以下操作
SELECT 
doi.ORDER_ID AS "PO"
, doi.DISTRIBUTOR_ID AS "Vendor ID"
, doi.ISBN AS "ASIN"
, doi.QUANTITY_ORDERED AS "Quantity Confirmed"
FROM D_DISTRIBUTOR_ORDER_ITEMS doi
JOIN PRODUCT_SEGMENT_MEMBERSHIP psm
ON doi.ISBN = psm.ASIN
WHERE psm.SEGMENT_ID = 784885
AND doi.ORDER_DAY = '2009/04/06'
ORDER BY psm.ASIN

当您尝试输入带有格式字符串的文字但是格式字符串的长度与字面值的长度不同时,您会得到ORA-01861并非绝对确定。

如果我没有错,那么问题在于doi.ORDER_DAY = '2009/04/06'行。尝试更改它,如下所示

TO_DATE(doi.ORDER_DAY,'yyyy/mm/dd') = '2009/04/06'

(OR)

doi.ORDER_DAY = TO_DATE('2009/04/06','yyyy/mm/dd')

答案 2 :(得分:0)

至于串行到并行,我无法找到解决方案,但它似乎是一个微不足道的问题,只会使查询花费几秒钟。正在看到的错误ORA-01861能够通过使用更改线来解决     doi.ORDER_DAY ='2009/04/06' 至     doi.ORDER_DAY = TO_DATE('20090406','YYYYMMDD')

这能够解决ORA-01861的问题。