[英]SQL query optimization Oracle
I have this SQL query that first selects from a relative short table a number that is used after for another select, this time from a very large table, certain info using the code from the first one. 我有这个SQL查询,它首先从一个相对短的表中选择一个数字,此数字用于另一个选择,这次是从一个很大的表中,使用第一个代码中的代码来确定某些信息。 This takes more than 30 minutes for only one select and i need to optimize as i have to run 300 selects like this one but with different SWNAMEs.
仅一次选择就花费了30多分钟,我需要优化,因为我必须像这样运行300个选择,但是要使用不同的SWNAME。 I would appreciate any hints and tips that you can give me.
如果您能给我任何提示,我将不胜感激。 Thank you !
谢谢 !
SELECT SWOBJECTID
FROM MBR_INST_PRODUCTS
WHERE SWPRODRELEASEID IN
(SELECT SWPRODRELEASEID
FROM ORO_PPY_OPTIONS
WHERE SWNAME LIKE 'Nov Flexibil Offer:Net Unlimited for 1MON')
AND rownum <2;
How about a simple join? 一个简单的联接怎么样?
SELECT m.swobjectid
FROM mbr_inst_products m
JOIN oro_ppy_options o ON o.swprodreleaseid = m.swprodreleaseid
WHERE o.swname = 'Nov Flexibil Offer:Net Unlimited for 1MON'
AND ROWNUM < 2;
Make sure swprodreleaseid
columns are indexed. 确保
swprodreleaseid
列已建立索引。
I would write this query as: 我将此查询写为:
SELECT ip.SWOBJECTID
FROM MBR_INST_PRODUCTS ip JOIN
ORO_PPY_OPTIONS po
ON po.SWPRODRELEASEID = ip.SWPRODRELEASEID
WHERE po.SWNAME = 'Nov Flexibil Offer:Net Unlimited for 1MON') AND
rownum = 1;
For this query, you want indexes on ORO_PPY_OPTIONS(SWNAME, SWPRODRELEASEID)
and MBR_INST_PRODUCTS(MBR_INST_PRODUCTS)
. 对于此查询,您需要在
ORO_PPY_OPTIONS(SWNAME, SWPRODRELEASEID)
和MBR_INST_PRODUCTS(MBR_INST_PRODUCTS)
上ORO_PPY_OPTIONS(SWNAME, SWPRODRELEASEID)
索引。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.