Changeset: cb9f120b9700 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=cb9f120b9700
Modified Files:
        sql/src/backends/monet5/sql.mx
        sql/src/sql/createdb.mx
Branch: default
Log Message:

Make footprint analysis possible
The user can analyse the actual database footprint
by inspecting the table returned from storage().


diffs (106 lines):

diff -r ddfaec9c6eb1 -r cb9f120b9700 sql/src/backends/monet5/sql.mx
--- a/sql/src/backends/monet5/sql.mx    Fri Jan 14 08:49:40 2011 +0100
+++ b/sql/src/backends/monet5/sql.mx    Fri Jan 14 10:59:56 2011 +0100
@@ -5647,7 +5647,7 @@
 Inspection of the actual storage footprint is a recurring question of users.
 This is modelled as a generic SQL table producing function.
 create function storage()
-returns table ("schema" string, "table" string, "column" string, location 
string, cnt bigint, cap bigint, width int, size bigint, auxsize bigint)
+returns table ("schema" string, "table" string, "column" string, location 
string, "count" bigint, capacity bigint, width int, size bigint, hashsize 
bigint)
 external name sql.storage;
 @c
 str
@@ -5662,6 +5662,7 @@
        str msg = getContext(cntxt,mb, &m, NULL);
        sql_trans *tr = m->session->tr;
        node *nsch, *ntab, *ncol;
+       int w;
 
        if (msg)
                return msg;
@@ -5707,36 +5708,40 @@
                for(ntab= (s)->tables.set->h ;ntab; ntab= ntab->next){
                        sql_base *bt= ntab->data;
                        t= (sql_table*) bt;
+                       if (isTable(t))
                        for (ncol= (t)->columns.set->h; ncol; ncol= ncol->next){
                                sql_base *bc = ncol->data;
                                sql_column *c= (sql_column *) ncol->data;
                                BAT *bn = store_funcs.bind_col(tr, c, 0);
                                BUN sz;
 
-                               printf("schema %s.%s.%s" , b->name, bt->name, 
bc->name);
-                               sch = BUNappend(sch, &b->name, FALSE);
-                               tab = BUNappend(tab, &bt->name, FALSE);
-                               col = BUNappend(col, &bc->name, FALSE);
-
-                               printf(" cnt "BUNFMT, BATcount(bn));
+                               //printf("schema %s.%s.%s" , b->name, bt->name, 
bc->name);
+                               sch = BUNappend(sch, b->name, FALSE);
+                               tab = BUNappend(tab, bt->name, FALSE);
+                               col = BUNappend(col, bc->name, FALSE);
+
+                               //printf(" cnt "BUNFMT, BATcount(bn));
                                sz= BATcount(bn);
                                cnt = BUNappend(cnt, &sz, FALSE);
-                               printf(" cap "BUNFMT, BATcapacity(bn));
+                               //printf(" cap "BUNFMT, BATcapacity(bn));
                                sz= BATcapacity(bn);
                                cap = BUNappend(cap, &sz, FALSE);
 
-                               printf(" loc %s", BBP_physical(bn->batCacheid));
-                               loc = BUNappend(loc, 
&BBP_physical(bn->batCacheid), FALSE);
-                               printf(" width %d", bn->T->width);
-                               atom = BUNappend(atom, &bn->T->width, FALSE);
-                               printf(" size "BUNFMT, 
tailsize(bn,BATcount(bn)) + (bn->T->vheap? bn->T->vheap->size:0));
-                               sz = tailsize(bn,BATcount(bn)) + (bn->T->vheap? 
bn->T->vheap->size:0);
+                               //printf(" loc %s", 
BBP_physical(bn->batCacheid));
+                               loc = BUNappend(loc, 
BBP_physical(bn->batCacheid), FALSE);
+                               //printf(" width %d", bn->T->width);
+                               w= bn->T->width;
+                               atom = BUNappend(atom, &w, FALSE);
+                               //printf(" size "BUNFMT, 
tailsize(bn,BATcount(bn)) + (bn->T->vheap? bn->T->vheap->size:0));
+                               sz = tailsize(bn,BATcapacity(bn)) + 
(bn->T->vheap? bn->T->vheap->size:0);
+                               sz += headsize(bn,BATcapacity(bn)) + 
(bn->H->vheap? bn->H->vheap->size:0);
                                size = BUNappend(size, &sz, FALSE);
                                
                                sz =  bn->T->hash?bn->T->hash->heap->size:0;
+                               sz += bn->H->hash?bn->H->hash->heap->size:0;
                                aux = BUNappend(aux, &sz, FALSE);
-                               printf(" auxsize "BUNFMT, 
bn->T->hash?bn->T->hash->heap->size:0);
-                               printf("\n");
+                               //printf(" auxsize "BUNFMT, 
bn->T->hash?bn->T->hash->heap->size:0);
+                               //printf("\n");
                                BBPunfix(bn->batCacheid);
                        }
                }
@@ -5747,11 +5752,11 @@
        BUNins(r, "table", &tab->batCacheid, FALSE);
        BUNins(r, "column", &col->batCacheid, FALSE);
        BUNins(r, "location", &loc->batCacheid, FALSE);
-       BUNins(r, "cnt", &cnt->batCacheid, FALSE);
-       BUNins(r, "cap", &cap->batCacheid, FALSE);
+       BUNins(r, "count", &cnt->batCacheid, FALSE);
+       BUNins(r, "capacity", &cap->batCacheid, FALSE);
        BUNins(r, "width", &atom->batCacheid, FALSE);
        BUNins(r, "size", &size->batCacheid, FALSE);
-       BUNins(r, "auxsize", &aux->batCacheid, FALSE);
+       BUNins(r, "hashsize", &aux->batCacheid, FALSE);
        BBPunfix(sch->batCacheid);
        BBPunfix(tab->batCacheid);
        BBPunfix(col->batCacheid);
diff -r ddfaec9c6eb1 -r cb9f120b9700 sql/src/sql/createdb.mx
--- a/sql/src/sql/createdb.mx   Fri Jan 14 08:49:40 2011 +0100
+++ b/sql/src/sql/createdb.mx   Fri Jan 14 10:59:56 2011 +0100
@@ -75,6 +75,11 @@
        returns table ("name" string, value string)
        external name sql.sql_environment;
 
+-- The database foot print
+create function storage()
+returns table ("schema" string, "table" string, "column" string, location 
string, "count" bigint, capacity bigint, width int, size bigint, hashsize 
bigint)
+external name sql.storage;
+
 -- The BAT buffer pool overview
 create function bbp () 
        returns table (id int, name string, htype string, 
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to