You are not logged in or registered. Please login or register to use the full functionality of this SYBASETEAM.COM Website...
Current time: 03-12-2010, 07:55 PM Hello There, Guest! (LoginRegister)
Tags: find, size, tables, indexes, tempdb,
Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
find out the size of tables and indexes in any tempdb
12-03-2009, 05:45 PM
Post: #1
find out the size of tables and indexes in any tempdb
Query to find out the size of tables and indexes in any Sybase tempdb
by : Mich Talebzadeh (Copyright)

Note: This has not been tested by me.Please try it yourself first, modify and post them here if required.

To find out the size of tables and indexes in any tempdb, the owners and the processes creating them, you can use the following stored procedure. However, you need to execute it in the tempdb database it is intended for:

use sybsystemprocs
go
create procedure sp__tempdb3
as
create table #trouble3 (name varchar(30), indid int, size int)
insert #trouble3
select a.name, b.indid, data_pgs(b.id, doampg)*1024/512
from tempdb3..sysobjects a,
tempdb3..sysindexes b
where a.id=b.id
and (b.indid <2) and a.type='U'
union
select a.name, b.indid, isnull(sum(data_pgs(b.id, ioampg))*1024/512,0)
from tempdb3..sysobjects a,
tempdb3..sysindexes b
where a.id=b.id and b.indid >1 and (a.type='U')
group by a.name, b.indid
select distinct substring(suser_name(p.suid),1,20) "User",
p.spid "Process",
a.name "Table",
a.indid,
size "Size in KB"
from #trouble3 a,
master..sysprocesses p
where a.name not like '#trouble3%'
and suser_name(p.suid) <> 'sa'
and
(
convert(int,substring(a.name,17,4)) = p.spid
OR convert(int,substring(a.name,18,5)) = p.spid
)
order by suser_name(p.suid),a.size desc
truncate table #trouble3
drop table #trouble3
go
grant all on sp__tempdb3 to public
go
exit


For example to find out all temporary work tables created in tempdb3, do the following:
use tempdb3
go
sp__tempdb3
go
User Process Table indid Size in KB
-------------------- ------- ------------------------------ ----------- -----------
jobserver 1033 #BH11________00010330010239290 0 18
jobserver 938 #BH14________00009380010240200 0 14
jobserver 1143 #BH9_________00011430010238698 0 10
jobserver 239 #BH20________00002390010242200 0 8
jobserver 1246 #BH4_________00012460010237517 0 6


Note that indid column has the usual values in sysindexes. For example “0” for the table itself, “1” for clustered index etc. In addition, you can somehow decipher the #table name and find out the name of the Sybase login creating it. The stored procedure code above should give you enough information about how to find this out.
Find all posts by this user
Quote this message in a reply

Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  SQL script to calculate sybase database size ,data free,data used,log free,log used sybaseteam 2 2,233 02-23-2010 01:59 PM
Last Post: sybanva
  How to get the max tempdb usage and max log file usage for user database till date GANESHBSUTAR 3 232 01-07-2010 10:49 PM
Last Post: Joshi
  Using Solaris tmpfs for a tempdb Device in Sybase ASE albert 0 106 12-20-2009 03:54 PM
Last Post: albert
  Tip-There is not enough memory in the procedure cache during the migration of indexes Joshi 0 98 12-04-2009 04:05 PM
Last Post: Joshi
  Common Problems with MDA Tables in Sybase ASE john 0 158 11-19-2009 12:45 PM
Last Post: john
  Do you know why Indexes Grow In Tables with TEXT Fields? Wondering? Kishor 1 94 09-29-2009 02:08 AM
Last Post: sybaseteam
  Query to find device name for each database fragment Nagendra 0 164 07-22-2009 11:06 AM
Last Post: Nagendra
  Using Solaris temp filesystem tmpfs for a Sybase tempdb device Kishor 0 100 07-01-2009 02:11 AM
Last Post: Kishor
  MDA tables basics john 0 149 06-16-2009 11:25 PM
Last Post: john
  How do I move sybase tempdb off of the Master Device? sybasegeek 0 137 04-27-2009 11:19 AM
Last Post: sybasegeek

Forum Jump: