Tech for good
Tech for good

Reputation: 187

Sybase - row count

Could these counts be different, ever? (in Sybase 15)

SELECT COUNT(1) FROM MY_TABLE 

and

select st.rowcnt 
from sysobjects ob, systabstats st 
where ob.name = "MY_TABLE"
and st.id=ob.id 

Upvotes: 1

Views: 3930

Answers (4)

Sam
Sam

Reputation: 1

yes, possible different due to concurrent DML on the table.

Upvotes: 0

sanjeev
sanjeev

Reputation: 13

Yes, both may be different. For example when there is change in the table like insert or delete the row. It takes some time to update rowcnt in the systabstats.

But when you use count(1) then it always returns exact count.

Upvotes: 1

Nishad
Nishad

Reputation: 426

This could be different , as data in stats table is not always/exact realtime

Upvotes: 0

RobV
RobV

Reputation: 2378

Yes, they can be different, for example when there is insert/delete activity going on for the table. That may be tricky to reproduce however.

Upvotes: 3

Related Questions