Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

why 1048576

9 posts in General Discussion Last posting was on 2011-11-11 16:57:33.0Z
djmodica Posted on 2011-11-10 21:05:08.0Z
Sender: 441f.4eb81ea0.1804289383@sybase.com
From: djmodica
Newsgroups: sybase.public.ase.general
Subject: why 1048576
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <4ebc3c84.750b.1681692777@sybase.com>
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 10 Nov 2011 13:05:08 -0800
X-Trace: forums-1-dub 1320959108 10.22.241.41 (10 Nov 2011 13:05:08 -0800)
X-Original-Trace: 10 Nov 2011 13:05:08 -0800, 10.22.241.41
Lines: 17
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:30662
Article PK: 73554

folks,
i have a proc which gets the size of a device in an ASE
15.0.3 as follows:

set disk_size =
ROUND(CONVERT(DECIMAL(14, 2),(d.high - d.low + 1))*
(@@pagesize / 1048576.0),2)
from master.dbo.sysdevices d, #dev_tbl
where d.status & 2 = 2
and #dev_tbl.name = d.name

it works great. i just don't understand WHY i am dividing
the allocated pages by @@pagesize / 1048576.0

could someone who knows please clue me in ?

thanks


Rob V Posted on 2011-11-10 21:34:34.0Z
From: Rob V <rob@DO.NOT.SPAM.sypron.nl.REMOVE.THIS.DECOY>
Reply-To: rob@DO.NOT.SPAM.sypron.nl.REMOVE.THIS.DECOY
Organization: Sypron BV
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1
MIME-Version: 1.0
Newsgroups: sybase.public.ase.general
Subject: Re: why 1048576
References: <4ebc3c84.750b.1681692777@sybase.com>
In-Reply-To: <4ebc3c84.750b.1681692777@sybase.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4ebc436a$1@forums-1-dub>
Date: 10 Nov 2011 13:34:34 -0800
X-Trace: forums-1-dub 1320960874 10.22.241.152 (10 Nov 2011 13:34:34 -0800)
X-Original-Trace: 10 Nov 2011 13:34:34 -0800, vip152.sybase.com
Lines: 43
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:30666
Article PK: 73561


On 10-Nov-2011 22:05, djmodica wrote:
> folks,
> i have a proc which gets the size of a device in an ASE
> 15.0.3 as follows:
>
> set disk_size =
> ROUND(CONVERT(DECIMAL(14, 2),(d.high - d.low + 1))*
> (@@pagesize / 1048576.0),2)
> from master.dbo.sysdevices d, #dev_tbl
> where d.status& 2 = 2
> and #dev_tbl.name = d.name
>
> it works great. i just don't understand WHY i am dividing
> the allocated pages by @@pagesize / 1048576.0
>
> could someone who knows please clue me in ?
>
> thanks

1048576 = 1024 * 1024.
This formula tries to give you the size of a device fragment in Mbyte. (try it: 512 pages = 1.0 (Mbyte) = 512 * (2048/1048576.0) )
However, it contains an error: by using @@pagesize, what the original programmer seemingly tried to do is take into account the server page size of the ASE server in question. Unfortunately, @@pagesize is the wrong variable for that, since this always returns a constant of 2048. Change this to @@maxpagesize, and the expression will work correctly for other page sizes than the default 2KB as well.

--
HTH,

Rob V.
-----------------------------------------------------------------
Rob Verschoor

Certified Sybase Professional DBA for ASE 15.0/12.5/12.0/11.5/11.0
and Replication Server 15.0.1/12.5 // TeamSybase

Author of Sybase books (order online at www.sypron.nl/shop):
"Tips, Tricks& Recipes for Sybase ASE"
"The Complete Sybase IQ Quick Reference Guide"
"The Complete Sybase ASE Quick Reference Guide"
"The Complete Sybase Replication Server Quick Reference Guide"

rob@NO.SPAM.sypron.nl | www.sypron.nl | Twitter: @rob_verschoor
Sypron B.V., The Netherlands | Chamber of Commerce 27138666
-----------------------------------------------------------------