If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Sybase > How to check log space from a script

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-13-03, 06:33
Breen Breen is offline
Registered User
 
Join Date: Mar 2002
Location: Ireland
Posts: 181
How to check log space from a script

Hi All,
I was looking to set up a script to check the log space for a particular database.
I know there is the sp_helpdb stored procedure but it produces too much output - is there a table or view that would be better for this information.
Thanks for any help,
Breen.
Reply With Quote
  #2 (permalink)  
Old 03-13-03, 07:07
Bernd Dulfer Bernd Dulfer is offline
Registered User
 
Join Date: Sep 2002
Location: Germany, near Aachen
Posts: 120
Reply With Quote
  #3 (permalink)  
Old 03-13-03, 07:49
Breen Breen is offline
Registered User
 
Join Date: Mar 2002
Location: Ireland
Posts: 181
Hi Bernd,
Thanks for your post but I was hoping for a sql script.
I found the below at your link:
1> select db_name(dbid), segmap, size, curunreservedpgs(dbid, lstart, unreserved
pgs) from master..sysusages where db_name(dbid)='MSB'
2> go
segmap size
------------------------------ ----------- ----------- -----------
MSB 3 51200 34568
MSB 0 25600 25448
MSB 3 1496064 1496064
MSB 4 524288 516944
(4 rows affected)
But I'm not sure how to link this to log space.
Could you help?
Cheers,
Breen.
Reply With Quote
  #4 (permalink)  
Old 03-13-03, 08:57
svelasco svelasco is offline
Registered User
 
Join Date: Jun 2002
Location: Argentina
Posts: 78
Wink

I think this is the easiest way

USE your_databases
go

SELECT data_pgs(8, doampg)
FROM sysindexes where id=8
go

bye

Sebastian
Reply With Quote
  #5 (permalink)  
Old 03-13-03, 09:31
Breen Breen is offline
Registered User
 
Join Date: Mar 2002
Location: Ireland
Posts: 181
Hi svelasco,
Could you talk me through your script.
What is id=8 actually?
Thanks for your reply and any help,
Breen.
Reply With Quote
  #6 (permalink)  
Old 03-13-03, 09:43
svelasco svelasco is offline
Registered User
 
Join Date: Jun 2002
Location: Argentina
Posts: 78
If you see into sysobjects, you will find that the syslogs allways is the id=8

select * from sysobjects where type = "S"

The "data_pgs" is an internal function of sybase to find out how many pages use an objects (read the manual for more information).

Bye

Sebastian
Reply With Quote
  #7 (permalink)  
Old 03-13-03, 10:44
Breen Breen is offline
Registered User
 
Join Date: Mar 2002
Location: Ireland
Posts: 181
Hi Sebastian,
Thank you for your help and I have just one further question to confirm:

1> select data_pgs(8,doampg)
2> from sysindexes where id=8
3> go

-----------
32

(1 row affected)

From this I would take it that there are 32 pages used for the log segment => 32 x 2k = 64k used.

Is this correct?
And again thanks for your help and patience,
Breen.
Reply With Quote
  #8 (permalink)  
Old 03-13-03, 11:06
svelasco svelasco is offline
Registered User
 
Join Date: Jun 2002
Location: Argentina
Posts: 78
Thumbs up

That correct,
also you can check with "DBCC CHECKTABLE(syslogs)"
You can try this in master Databases (in a test server)

USE master
go

SELECT data_pgs(8, doampg)
FROM sysindexes where id=8
go

-- if you dont backup the transaction log !!!!!!
DUMP TRANSACTION master WITH TRUNCATE_ONLY
go

SELECT data_pgs(8, doampg)
FROM sysindexes where id=8
go

8 pages

DBCC CHECKTABLE(syslogs)
go

will say 1 pages

In fact, the syslogs have take an extends that have 8 pages, but only use 1 page from this.
If are you checking the spaces, then is more usefull the pages take by extends, that it's the select, because the server take by extends(8pages) from the databases.

bye

Sebastian
Reply With Quote
  #9 (permalink)  
Old 03-13-03, 11:34
Breen Breen is offline
Registered User
 
Join Date: Mar 2002
Location: Ireland
Posts: 181
Thanks for all your help Sebastian.
Breen.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On