sql - "Select count (*)" vs count of results from "Select 1" : which is more efficient way to get the rows count in DB2? -


i have 2 approaches count of rows in table in db2. 1 way is

select count(*) foo col1 = val1; 

another way count results (number 1's list) retrived following query method in java code

select 1 foo col1 = val1; 

here "list of number 1's" second query , size of list in java code count.

can explain efficient way rows count ?

select count faster - because database needs return single number rather potentially long list.


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -