我正在执行查询以查找正确的版本和数据迭代(请参阅下面的SQL)。
SELECT WTPartMaster.WTPARTNUMBER AS PartNumber ,
WTPartMaster.name AS "Name",
wtpart.VERSIONIDA2VERSIONINFO
||'.'
|| wtpart.ITERATIONIDA2ITERATIONINFO AS "Version",
wtpart.ida2a2
FROM wtpart,
WTPartMaster,
(SELECT MAX(wp.branchIditerationInfo) AS MAX,
wp.idA3masterReference
FROM wtpart wp
GROUP BY wp.idA3masterReference
) branchmax
WHERE wtpart.IDA3MASTERREFERENCE = WTPartMaster.ida2a2
AND WTPartMaster.wtpartnumber = '07011796'
AND wtpart.LATESTITERATIONINFO = 1
AND wtpart.branchiditerationinfo IN (branchmax.max)
ORDER BY PartNumber ;
当我添加条件以检查列WHERE NOT REGEXP_LIKE(wp.VERSIONIDA2VERSIONINFO, '\.')
是否具有多个字符或点(。)时,在没有该条件的情况下执行需要约2秒,需要约0.2秒。有没有办法可以提高这个查询的性能?
我也试过LENGTH
。
SELECT WTPartMaster.WTPARTNUMBER AS PartNumber ,
WTPartMaster.name AS "Name",
wtpart.VERSIONIDA2VERSIONINFO
||'.'
|| wtpart.ITERATIONIDA2ITERATIONINFO AS "Version",
wtpart.ida2a2
FROM wtpart,
WTPartMaster,
(SELECT MAX(wp.branchIditerationInfo) AS MAX,
wp.idA3masterReference
FROM wtpart wp
where NOT REGEXP_LIKE(wp.VERSIONIDA2VERSIONINFO, '\.')
GROUP BY wp.idA3masterReference
) branchmax
WHERE wtpart.IDA3MASTERREFERENCE = WTPartMaster.ida2a2
AND WTPartMaster.wtpartnumber = '07011796'
AND wtpart.LATESTITERATIONINFO = 1
AND wtpart.branchiditerationinfo IN (branchmax.max)
ORDER BY PartNumber ;