Written by

Question Paul Riker · Jul 11, 2016

Database Table Size

Hi All,

We are doing capacity planning. I want to track the number of rows and size of each table (or at least the top ~10). Any ideas?

Thanks

Comments

Henrique Dias · Jul 11, 2016

If you use the command d ^%GSIZE the result will be something like this:
      Global        Blocks       Bytes Used  Packing   Contig.
      --------    --------  ---------------  -------   -------
      Aviation.AircraftD
                        64          455,452     87 %        62
      Aviation.AircraftI
                         4           27,300     84 %         2
      Aviation.Countries
                         1            4,300     53 %         0
      Aviation.CrewI
                         5           36,824     90 %         3
      Aviation.EventD
                     1,153        6,980,501     74 %       649
      Aviation.EventI
                         3           19,020     78 %         1
      Aviation.States
                         1              820     10 %         0
      CacheMsg           6           30,040     61 %         0
      Cinema.ReviewD
                         1            4,012     49 %         0

Maybe this command could help you.

I hope that helps

0
Paul Riker  Jul 22, 2016 to Henrique Dias

I'm new to this so I'm sure it's me, but I get 

do ^%GSIZE
Directory name: /hs/data/mgr/ensemble/ =>
All Globals? No => No
Global ^
0 globals selected from 187 available globals.
No globals were selected!

0
Henrique Dias  Jul 22, 2016 to Paul Riker

Paul, 

When the command ^%GSIZE asked if you wanted "All Globals", your aswer was No


All Globals? No => No
Global ^
0 globals selected from 187 available globals.

So, the command do not selected no globals of your 187 globals.


Try to answer Yes instead and look what happens after.

0
Paul Riker  Aug 22, 2016 to Henrique Dias

This worked like a charm, thanks! What I didn't realize is that using commands in studio vs. cscession hiecontroller is different. Can I check the size of a specific table?

0
Martin Fukátko · Jul 12, 2016

Try to look at query  Size in class %SYS.GlobalQuery

HTH

0
Paul Riker  Jul 22, 2016 to Martin Fukátko

Can you tell me the specific syntax? Should I just be able to run %SYS.GlobalQuery?

0
David Loveluck  Jul 22, 2016 to Paul Riker

there is a thread about class queries that gives a full explanation but in this specific case you could do ...

   set statement=##class(%SQL.Statement).%New()
    set status=statement.%PrepareClassQuery("%SYS.GlobalQuery","Size")
   set resultset=statement.%Execute("c:\intersystems\ens20163a\mgr\ensemble","","*")
    while resultset.%Next() {
        write !, resultset.%Get("Name"),", "                                       
        write resultset.%Get("Allocated MB"),", "    
        write resultset.%Get("Used MB")
     }

0
Mateus Anacleto · Sep 1, 2016

I did a logic to read all globals of the namespace and show only the globals that have the size larger than 100 mb:

VerGlobal    
    new global,set,tamanho,qtde
    set (global,qtde)=""
    kill ^mtempTAMANHOGLO
    for  {
        set global=$order(^$global(global)) quit:global=""
        set sc=##class(%Library.GlobalEdit).GetGlobalSize($zu(12,""),global,.tamanho,,1)
        set qtde=qtde+1
        set ^mtempLISTA(global)=global    
        if tamanho>100 {
            set ^mtempTAMANHOGLO(tamanho,global)=global            
        }
        w #
        write !, "Quantidade de globais verificadas "_qtde
    }    
    
    quit 1

0