Reputation: 187
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
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
Reputation: 426
This could be different , as data in stats table is not always/exact realtime
Upvotes: 0
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