Posted: Sun Feb 07, 2010 8:37 am Post subject: Performance of a query.
Hi,
Not sure whether its just a stupid question..
In one of my code.. I have written one query to fetch some data and the query is like below..
Code:
SELECT A.COLNAME1
,A.COLNAME2
,A.COLNAME3
,A.COLNAME4
INTO :COL-NAME1
,:COL-NAME2
,:COL-NAME3
,:COL-NAME4
FROM TABLE_NAME A
WHERE A.COLNAME1 = :WS-COL-NAME
AND A.COLNAME2 = :YYYYYYYY
AND A.COLNAME3 = :ZZZZZZZZ
AND A.COLNAME5 = (SELECT MAX (COLNAME5)
FROM TABLE_NAME
WHERE A.COLNAME1 = COLNAME1
AND A.COLNAME2 = COLNAME2
AND A.COLNAME3 = COLNAME3
AND A.COLNAME4 = COLNAME4
AND A.COLNAME6 = COLNAME6 )
and my DBA asked to change it like this...
Code:
SELECT A.COLNAME1
,A.COLNAME2
,A.COLNAME3
,A.COLNAME4
INTO :COL-NAME1
,:COL-NAME2
,:COL-NAME3
,:COL-NAME4
FROM TABLE_NAME A
WHERE A.COLNAME1 = :WS-COL-NAME
AND A.COLNAME2 = :YYYYYYYY
AND A.COLNAME3 = :ZZZZZZZZ
AND A.COLNAME5 = (SELECT MAX (COLNAME5)
FROM TABLE_NAME B
WHERE A.COLNAME1 = B.COLNAME1
AND A.COLNAME2 = B.COLNAME2
AND A.COLNAME3 = B.COLNAME3
AND A.COLNAME4 = B.COLNAME4
AND A.COLNAME6 = B.COLNAME6 )
( Notice the difference in the sub-query )
I know both will fetch the same data.. but just want to know is there any performance difference will be noticed with these 2 queries ?
Joined: 31 May 2004 Posts: 391 Topics: 4 Location: Richfield, MN, USA
Posted: Mon Feb 08, 2010 12:05 am Post subject:
I don't think there's a performance difference. Maybe his suggestion was for the purpose of making the query more explicit as far as readability or understandability is concerned? Did you ask what the reasoning of the DBA was? _________________ ....Terry
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum