Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups 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 SQL - select data available in index Nileshkul DB2 3 Mon Jun 26, 2017 1:30 am
No new posts CICS Transaction attach count of supp... lind sh CICS 1 Wed Jun 21, 2017 1:33 pm
No new posts Need DB2 query to fetch previous row ! Chandan1993 DB2 10 Sat Jun 03, 2017 10:43 am
No new posts Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
This topic is locked: you cannot edit posts or make replies. Merge two files and update Trailer re... Yashashri JCL & VSAM 1 Thu May 04, 2017 12:54 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us