Bench mark yourself:
I do not think it will make a big difference:
select getdate()
go
select count(*) from syscolumns where object_name(id) = 'employee'
go
select getdate()
go
select count(1) from syscolumns where object_name(id) = 'employee'
go
select getdate()
go
Now, measure the time and see which is faster.
Main Topics
Browse All Topics





by: knel1234Posted on 2004-01-28 at 07:59:52ID: 10219066
Rose,
The reason to use count(1) instead of count(*) is simple.
If you use count(*), then you are instructing sybase to fetch the complete row of table ABC. If your table has 20 columns totalling 1024K, then sybase must fetch all these bytes (note they are NOT returned to your query but they are touched in the process). If you use count(1) then sybase is just "handling" the 1 byte. This is usually a minor P&T issue, but why not start coding all your queries this way. All those IOs can add up over time.
As far as the sp_spaceused, you might want to go to
www.edbarlow.com then look at his SPs (specifically sp__helptable).
In general
If you find a sybase SP that you like, then the thing to to is to create
a modified version of this SP and save it as "sp__xxxxx". Basically, the double underscore indicates a "homegrown" or internal SP.
hope this helps
knel