Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
DB2 COUNT(*) Vs Select 1 Query

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
ramanindya55

New User


Joined: 23 May 2008
Posts: 9
Location: pune

PostPosted: Tue Mar 17, 2009 2:32 pm    Post subject: DB2 COUNT(*) Vs Select 1 Query
Reply with quote

Hi,
I want to write a query for checking any existence of any row.
Can u plz tell me which one would be best considering the Performance parameter?

Code:
 
EXEC SQL                         
    SELECT COUNT(*)             
     INTO :stud-count
     FROM Student
     WHERE Degree = :WS-Degree   
END-EXEC.                       

Here is my "Select 1" query
Code:
 
EXEC SQL                         
    SELECT  1
     INTO :stud-count
     FROM Student
     WHERE Degree = :WS-Degree   
END-EXEC.                       
Back to top
View user's profile Send private message

Bharath Bhat

Active User


Joined: 20 Mar 2008
Posts: 283
Location: chennai

PostPosted: Tue Mar 17, 2009 2:58 pm    Post subject:
Reply with quote

If its mere existence check, SELECT 1 is better.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Create procedure issues -628 when add... chandraBE DB2 1 Mon Sep 18, 2017 12:16 pm
No new posts column with count of rows within dist... ronald wouterson DB2 4 Sun Sep 17, 2017 9:48 pm
No new posts Updating the Trailer count in variabl... satheshbabur DFSORT/ICETOOL 6 Wed Aug 30, 2017 9:49 pm
No new posts SORT Trailer Count - LRECL Output co... amorante DFSORT/ICETOOL 5 Tue Aug 29, 2017 8:57 pm
No new posts Can we limit length in concatenation ... balaji81_k DB2 7 Tue Aug 22, 2017 2:50 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us