Update of /cvsroot/monetdb/sql/src/storage/restrict
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv530/src/storage/restrict
Modified Files:
Tag: Nov2009
restrict_storage.mx restrict_table.mx
Log Message:
fixed performance issue with loading (in readonly mode) complex schema's
Index: restrict_table.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/storage/restrict/restrict_table.mx,v
retrieving revision 1.6
retrieving revision 1.6.2.1
diff -u -d -r1.6 -r1.6.2.1
--- restrict_table.mx 12 Aug 2009 17:41:34 -0000 1.6
+++ restrict_table.mx 19 Nov 2009 20:42:01 -0000 1.6.2.1
@@ -44,19 +44,34 @@
#include "restrict_storage.h"
static BAT *
-full_column(sql_column *c, BAT *d, BAT *s )
+full_column_(sql_column *c, BAT *d, BAT *s )
{
sql_bat *bat = c->data;
BAT *r, *b = temp_descriptor(bat->bid);
+
if (s) {
BAT *t = BATsemijoin(b,s); bat_destroy(b); b = t;
}
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;
}
+static BAT *
+full_column(sql_column *c, BAT *d, BAT *s )
+{
+ sql_bat *bat = c->data;
+
+ if (bat->cached && s)
+ return BATsemijoin(bat->cached, s);
+ if (bat->cached)
+ return temp_descriptor(bat->cached->batCacheid);
+ return full_column_( c, d, s);
+}
+
static oid
column_find_row(sql_trans *tr, sql_column *c, void *value, ...)
{
Index: restrict_storage.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/storage/restrict/restrict_storage.mx,v
retrieving revision 1.18
retrieving revision 1.18.2.1
diff -u -d -r1.18 -r1.18.2.1
--- restrict_storage.mx 12 Aug 2009 17:41:30 -0000 1.18
+++ restrict_storage.mx 19 Nov 2009 20:42:01 -0000 1.18.2.1
@@ -29,6 +29,7 @@
int bid;
int ubid; /* bat with old updated values (su only) */
size_t cnt; /* number of tuples (excluding the deletes) */
+ BAT *cached; /* cached copy, used for schema bats only */
} sql_bat;
#define bat_set_access(b,access) b->P->restricted = access
@@ -103,8 +104,13 @@
static void
update_bat( sql_bat *bat, BAT *upd, int isnew)
{
- BAT *b = temp_descriptor(bat->bid);
+ BAT *b;
+ if (bat->cached) {
+ bat_destroy(bat->cached);
+ bat->cached = NULL;
+ }
+ b = temp_descriptor(bat->bid);
if (!isnew) {
BAT *u = NULL;
BAT *old = BATkdiff(b, upd), *r;
@@ -131,6 +137,10 @@
BAT *b;
assert(rid != oid_nil);
+ if (bat->cached) {
+ bat_destroy(bat->cached);
+ bat->cached = NULL;
+ }
b = temp_descriptor(bat->bid);
if (!isnew) {
BAT *u = NULL;
@@ -192,6 +202,10 @@
{
BAT *b = temp_descriptor(bat->bid);
+ 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){
temp_destroy(bat->bid);
@@ -206,8 +220,13 @@
static void
append_val( sql_bat *bat, void *i )
{
- BAT *b = temp_descriptor(bat->bid);
+ BAT *b;
+ if (bat->cached) {
+ bat_destroy(bat->cached);
+ bat->cached = NULL;
+ }
+ b = temp_descriptor(bat->bid);
BUNappend(b, i, TRUE);
bat->cnt ++;
bat_destroy(b);
@@ -265,8 +284,32 @@
static void
delete_tab(sql_trans *tr, sql_table * t, void *ib, int tpe)
{
+ node *n;
sql_bat *bat = t->data;
+ /* delete all cached copies */
+ for (n = t->columns.set->h; n; n = n->next) {
+ sql_column *c = n->data;
+ sql_bat *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_bat *bat = i->data;
+
+ if (bat->cached) {
+ bat_destroy(bat->cached);
+ bat->cached = NULL;
+ }
+ }
+ }
+
+
t->base.wtime = t->s->base.wtime = tr->wtime = tr->stime;
t->base.rtime = t->s->base.rtime = tr->rtime = tr->stime;
if (tpe == TYPE_bat)
@@ -609,8 +652,11 @@
temp_destroy(b->bid);
if (b->ubid)
temp_destroy(b->ubid);
+ if (b->cached)
+ temp_destroy(b->cached->batCacheid);
b->bid = b->ubid = 0;
b->name = NULL;
+ b->cached = NULL;
_DELETE(b);
return 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