Update of /cvsroot/monetdb/sql/src/storage/bat
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv21419/src/storage/bat
Modified Files:
bat_storage.mx bat_table.mx
Log Message:
During startup we cache delta's (ie b,i,u,del into one bat).
This improves startup on complex databases (should improve startup of Skyserver)
U bat_table.mx
Index: bat_table.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/storage/bat/bat_table.mx,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- bat_table.mx 12 Aug 2009 17:41:13 -0000 1.40
+++ bat_table.mx 12 Sep 2009 20:40:45 -0000 1.41
@@ -48,7 +48,7 @@
/* initialize bat storage call back functions interface */
extern int bat_table_init( table_functions *tf );
-extern BAT* delta_full_bat( sql_delta *bat, int temp, BAT *d, BAT *s);
+extern BAT* delta_full_bat( sql_column *c, sql_delta *bat, int temp, BAT *d,
BAT *s);
#endif /*BAT_TABLE_H*/
@c
@@ -57,7 +57,7 @@
#include "bat_utils.h"
BAT *
-delta_full_bat( sql_delta *bat, int temp, BAT *d, BAT *s)
+delta_full_bat_( sql_column *c, sql_delta *bat, int temp, BAT *d, BAT *s)
{
/* return full normalized column bat
@@ -103,13 +103,25 @@
if (d && BATcount(d)) {
r = BATkdiff(b,BATmirror(d)); bat_destroy(b); b = r;
}
+ if (!bat->cached && !c->base.wtime && !s)
+ bat->cached = temp_descriptor(b->batCacheid);
return b;
}
+BAT *
+delta_full_bat( sql_column *c, sql_delta *bat, int temp, BAT *d, BAT *s)
+{
+ if (bat->cached && s)
+ return BATsemijoin(bat->cached, s);
+ if (bat->cached)
+ return temp_descriptor(bat->cached->batCacheid);
+ return delta_full_bat_( c, bat, temp, d, s);
+}
+
static BAT *
full_column(sql_column *c, BAT *d, BAT *s )
{
- return delta_full_bat(c->data, isTemp(c), d, s);
+ return delta_full_bat(c, c->data, isTemp(c), d, s);
}
static oid
U bat_storage.mx
Index: bat_storage.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/storage/bat/bat_storage.mx,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- bat_storage.mx 18 Aug 2009 11:41:28 -0000 1.45
+++ bat_storage.mx 12 Sep 2009 20:40:45 -0000 1.46
@@ -31,6 +31,7 @@
int ibid; /* bat with inserts */
int ubid; /* bat with updates */
size_t cnt; /* number of tuples (excluding the deletes) */
+ BAT *cached; /* cached copy, used for schema bats only */
} sql_delta;
typedef struct sql_dbat {
@@ -177,6 +178,10 @@
{
BAT *b;
+ if (bat->cached) {
+ bat_destroy(bat->cached);
+ bat->cached = NULL;
+ }
if (!is_new && bat->ubid) {
BAT *ib = temp_descriptor(bat->ibid), *u = upd;
@@ -235,6 +240,10 @@
assert(rid != oid_nil);
+ if (bat->cached) {
+ bat_destroy(bat->cached);
+ bat->cached = NULL;
+ }
if (bat->ubid) {
b = temp_descriptor(bat->ubid);
assert(b);
@@ -285,6 +294,10 @@
{
BAT *b = temp_descriptor(bat->ibid);
+ if (bat->cached) {
+ bat_destroy(bat->cached);
+ bat->cached = NULL;
+ }
bat->cnt += BATcount(i);
if ( BATcount(b) == 0 && !isVIEW(i) && i->htype == TYPE_void &&
i->ttype != TYPE_void && bat->ibase == i->H->seq){
temp_destroy(bat->ibid);
@@ -308,6 +321,10 @@
{
BAT *b = temp_descriptor(bat->ibid);
+ if (bat->cached) {
+ bat_destroy(bat->cached);
+ bat->cached = NULL;
+ }
if (isEbat(b)) {
bat_destroy(b);
temp_destroy(bat->ibid);
@@ -386,6 +403,29 @@
delete_tab(sql_trans *tr, sql_table * t, void *ib, int tpe)
{
sql_dbat *bat = t->data;
+ node *n;
+
+ /* delete all cached copies */
+ for (n = t->columns.set->h; n; n = n->next) {
+ sql_column *c = n->data;
+ sql_delta *bat = c->data;
+
+ if (bat->cached) {
+ bat_destroy(bat->cached);
+ bat->cached = NULL;
+ }
+ }
+ if (t->idxs.set) {
+ for (n = t->idxs.set->h; n; n = n->next) {
+ sql_idx *i = n->data;
+ sql_delta *bat = i->data;
+
+ if (bat->cached) {
+ bat_destroy(bat->cached);
+ bat->cached = NULL;
+ }
+ }
+ }
/* deletes only write */
t->base.wtime = t->s->base.wtime = tr->wtime = tr->stime;
@@ -914,8 +954,11 @@
temp_destroy(b->ubid);
if (b->bid)
temp_destroy(b->bid);
+ if (b->cached)
+ temp_destroy(b->cached->batCacheid);
b->bid = b->ibid = b->ubid = 0;
b->name = NULL;
+ b->cached = NULL;
return LOG_OK;
}
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins