IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

DB2 COUNT(*) Vs Select 1 Query


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts To get the count of rows for every 1 ... DB2 3
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts RC query -Time column CA Products 3
No new posts Validating record count of a file is ... DFSORT/ICETOOL 13
No new posts Dynamically pass table name to a sele... DB2 2
Search our Forums:

Back to Top