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

c# - Unity IoC Lifetime per HttpRequest for UserStore -

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -