Skip navigation

AIOUG Social Group

1 Post authored by: Akshs

We heard count(1) is faster then count(*).  Lets do a workshop on this .

 

TABLE_STRACTURE.png

Above is Copy_customer table where inserted both null and not null values.

lets execute  the queries   Count(*)  and count(1) and  verify the result  and verify the work load.

count_star

count_1

In both cases query will return the same output. Now lets compare the work load of both the queries.

Let's check for count(*)

count_star_tk

Now Count(1)

count_1_tk

From  the above screen shot its clearly shows both  queries are taking  same amount of  work load to execute.

Now lets verify the same query  output and work load with actual column name instead  of '1' and '*'.

cnt_column-name.png

Now if check the below output it will ignore the null from the result and trace file also using the index.cnt_c_id-tk.png

Here Elapsed time is little more to count(1) and count(*). Because here it also fetches more then 90% record. This article is only to demonstrate count(1) and count(*) are same.

 

Thank you....for eading