Update of /cvsroot/monetdb/sql/src/storage/bat
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv23009/src/storage/bat
Modified Files:
bat_sequence.mx bat_store.mx
Log Message:
Many fixes
changed how we handle selections over multiple columns of a single table
(should solve the preformance problem reported by Venks)
added a way to bulk request sequence numbers. When loading (copying) data
into tables which have a auto_increment (or alike) column lots of time
was spend in the many calls to get all the sequence numbers (observed a
performance in crease of about 10x when loading pieces of 100K rows)
added support for TINYINT (we map this too 'bte')
improved mapping functions onto the same signature too improve cached
function reuse
Index: bat_store.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/storage/bat/bat_store.mx,v
retrieving revision 1.140
retrieving revision 1.141
diff -u -d -r1.140 -r1.141
--- bat_store.mx 15 Jun 2007 14:32:43 -0000 1.140
+++ bat_store.mx 29 Jun 2007 11:29:10 -0000 1.141
@@ -694,7 +694,7 @@
fk->rkey = NULL;
fk->on_delete = action & 255;
- fk->on_update = (action>>8) && 255;
+ fk->on_update = (action>>8) & 255;
}
cols = BATselect(kc_id, (ptr) &nk->base.id, (ptr) &nk->base.id);
@@ -3786,7 +3786,7 @@
cur = temp_descriptor(oc->bat.bid);
if (ft->cleared && ttr == gtrans) {
bat_clear(cur);
- BATcommit(cur);
+ BATcommit(cur);
ok = log_bat_clear(sql_logger, oc->bat.name);
if (ok == LOG_OK)
ok = log_bat_clear(sql_logger, oc->bat.uname);
@@ -3826,6 +3826,9 @@
ins = cur;
cur = swpbat;
} else {
+ if (BATcount(cur)+BATcount(ins) >
(size_t) REMAP_PAGE_MAXSIZE) { /* try to use mmap() */
+ BATmmap(cur, STORE_MMAP,
STORE_MMAP, STORE_MMAP);
+ }
BATappend(cur,ins,TRUE);
bat_clear(ins);
}
@@ -3938,6 +3941,9 @@
ins = cur;
cur = swpbat;
} else {
+ if (BATcount(cur)+BATcount(ins)
> (size_t) REMAP_PAGE_MAXSIZE) { /* try to use mmap() */
+ BATmmap(cur,
STORE_MMAP, STORE_MMAP, STORE_MMAP);
+ }
BATappend(cur,ins,TRUE);
bat_clear(ins);
}
Index: bat_sequence.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/storage/bat/bat_sequence.mx,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- bat_sequence.mx 20 Feb 2007 11:50:47 -0000 1.19
+++ bat_sequence.mx 29 Jun 2007 11:29:09 -0000 1.20
@@ -23,6 +23,20 @@
extern void sequences_exit(void);
extern int seq_next_value(sql_sequence *seq, lng *val);
+
+/* for bulk next values, the API is split in 3 parts */
+
+typedef struct seqbulk {
+ void *internal_seq;
+ sql_sequence *seq;
+ int cnt;
+ int save;
+} seqbulk;
+
+extern seqbulk *seqbulk_create(sql_sequence *seq, int cnt);
+extern int seqbulk_next_value(seqbulk *seq, lng *val);
+extern void seqbulk_destroy(seqbulk *seq);
+
extern int seq_get_value(sql_sequence *seq, lng *val);
extern int seq_restart(sql_sequence *seq, lng start);
@@ -178,6 +192,85 @@
return 1;
}
+seqbulk *seqbulk_create(sql_sequence *seq, int cnt)
+{
+ seqbulk *sb = NEW(seqbulk);
+ bat_sequence *s;
+ node *n = NULL;
+
+ if (!sb)
+ return NULL;
+
+ store_lock();
+ sb->seq = seq;
+ sb->cnt = cnt;
+ sb->save = 0;
+
+ for ( n = sql_seqs->h; n; n = n ->next ) {
+ s = n->data;
+ if (s->seqid == seq->base.id)
+ break;
+ }
+ if (!n) {
+ s = sql_create_sequence(seq);
+ if (!s) {
+ _DELETE(sb);
+ return NULL;
+ }
+ list_append(sql_seqs, s);
+ } else {
+ s = n->data;
+ }
+ sb->internal_seq = s;
+ return sb;
+}
+
+void seqbulk_destroy(seqbulk *sb)
+{
+
+ if (sb->save) {
+ sql_sequence *seq = sb->seq;
+ bat_sequence *s = sb->internal_seq;
+
+ sql_update_sequence_cache(seq, s->cached);
+ }
+ _DELETE(sb);
+ store_unlock();
+}
+
+int seqbulk_next_value(seqbulk *sb, lng *val)
+{
+ lng nr = 0;
+ bat_sequence *s = sb->internal_seq;
+ sql_sequence *seq = sb->seq;
+
+ if (s->called)
+ s->cur += seq->increment;
+
+ /* handle min/max and cycle */
+ if ((seq->maxvalue && s->cur > seq->maxvalue) ||
+ (seq->minvalue && s->cur < seq->minvalue))
+ {
+ if (seq->cycle) {
+ /* cycle to the min value again */
+ s->cur = seq->minvalue;
+ sb->save = 1;
+ } else { /* we're out of numbers */
+ return(0);
+ }
+ }
+ s->called = 1;
+ nr = s->cur;
+ *val = nr;
+ if (nr == s->cached) {
+ s->cached = nr + seq->cacheinc*seq->increment;
+ sb->save = 1;
+ return 1;
+ }
+ assert(nr<s->cached);
+ return 1;
+}
+
int
seq_get_value(sql_sequence *seq, lng *val)
{
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins