| View previous topic :: View next topic |
| Author |
Message |
sudharsan100 Beginner

Joined: 05 Dec 2006 Posts: 2 Topics: 1
|
Posted: Mon Apr 09, 2007 10:48 pm Post subject: Existence Check |
|
|
Hi ,
Could some tell me which of the following existence check query efficient in DB2 V.8 and why ?
(1).
| Code: |
EXEC SQL
SELECT 'X'
INTO :WS-EXISTS
FROM SYSIBM.SYSDUMMY1 SYS
WHERE EXISTS
(SELECT 'X'
FROM XXX
WHERE XXX_XX = :XXX-XX
AND SYS.IBMREQD = SYS.IBMREQD)
END-EXEC.
|
(2).
| Code: |
EXEC SQL
SELECT 'X'
INTO :WS-EXISTS
FROM XXX
WHERE XXX_XXP = :XXX-XX
FETCH FIRST 1 ROW ONLY
END-EXEC
|
Thanks. |
|
| Back to top |
|
 |
vkphani Intermediate

Joined: 05 Sep 2003 Posts: 483 Topics: 48
|
Posted: Tue Apr 10, 2007 1:16 am Post subject: |
|
|
Efficient in what factors? Performance or Time or something else?
Time to execute your second query is less than that of the first query. So, second query is more efficient if you are taking Time into consideration. |
|
| Back to top |
|
 |
sudharsan100 Beginner

Joined: 05 Dec 2006 Posts: 2 Topics: 1
|
Posted: Tue Apr 10, 2007 2:45 am Post subject: |
|
|
| While considering into DB2 CPU and Cost factor. Please advise. |
|
| Back to top |
|
 |
bauer Intermediate
Joined: 10 Oct 2003 Posts: 319 Topics: 51 Location: Germany
|
Posted: Tue Apr 10, 2007 3:55 am Post subject: |
|
|
sudharsan100,
did you try the explain command? What are the results of explain ? |
|
| Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12399 Topics: 75 Location: San Jose
|
|
| Back to top |
|
 |
|
|
|