Changeset: e349732a4384 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/e349732a4384
Modified Files:
        sql/storage/bat/bat_storage.c
Branch: faster_segs_end
Log Message:

Improve segs_end performance

Reduces the computation time required in the segs_end function, which could 
become a bottleneck due to acquiring a table lock and because it is called many 
times per transaction. The apparent tradeoff is that down the line more blocks 
might need to be filtered, but the advantages outweigh this.


diffs (34 lines):

diff --git a/sql/storage/bat/bat_storage.c b/sql/storage/bat/bat_storage.c
--- a/sql/storage/bat/bat_storage.c
+++ b/sql/storage/bat/bat_storage.c
@@ -412,19 +412,19 @@ static size_t
 segs_end( segments *segs, sql_trans *tr, sql_table *table)
 {
        size_t cnt = 0;
-
        lock_table(tr->store, table->base.id);
-       segment *s = segs->h, *l = NULL;
-
-       if (segs->t && SEG_IS_VALID(segs->t, tr))
-               l = s = segs->t;
-
-       for(;s; s = s->next) {
-               if (SEG_IS_VALID(s, tr))
-                               l = s;
+       if (segs->t) {
+               cnt = segs->t->end;
        }
-       if (l)
-               cnt = l->end;
+       else { /* shouldn't really happen but its here just in case */
+               segment *s = segs->h;
+               while (s->next) {
+                       s = s->next;
+               }
+               if (s) {
+                       cnt = s->end;
+               }
+       }
        unlock_table(tr->store, table->base.id);
        return cnt;
 }
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to