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 query to fetch record which has only ... maxsubrat DB2 12 Mon Dec 11, 2017 5:03 pm
No new posts ISMF Difference between volume count ... upendrasri IBM Tools 2 Tue Dec 05, 2017 12:40 pm
No new posts How to query MAXGENS of an existing P... Chuchulo Hatyzak JCL & VSAM 4 Wed Nov 22, 2017 10:23 pm
No new posts Native SQL Query kishpra DB2 1 Wed Nov 22, 2017 8:38 pm
No new posts Query on IEFBR14 with GDG Ashishpanpaliya JCL & VSAM 4 Tue Nov 07, 2017 8:34 pm

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