aboutsummaryrefslogtreecommitdiff
path: root/GradeBook.tcl
diff options
context:
space:
mode:
authorEugeniy Mikhailov <evgmik@gmail.com>2013-12-05 09:25:46 -0500
committerEugeniy Mikhailov <evgmik@gmail.com>2013-12-05 09:25:46 -0500
commitf1e16fdd76c427ed5de1eb1ab7c856b81ca9fd0b (patch)
tree4326e9e917805e44d1b9aff9a6b352d3a84ce255 /GradeBook.tcl
parente15d379d45e78e33d6ee54504f538526480dbc66 (diff)
downloadGradeBook-f1e16fdd76c427ed5de1eb1ab7c856b81ca9fd0b.tar.gz
GradeBook-f1e16fdd76c427ed5de1eb1ab7c856b81ca9fd0b.zip
Access to database wrapped in one transaction
This speedups weights recalculations which use a lot of update statements. Strangely on some computers it works fast even without enabling one transaction mode.
Diffstat (limited to 'GradeBook.tcl')
-rwxr-xr-xGradeBook.tcl20
1 files changed, 20 insertions, 0 deletions
diff --git a/GradeBook.tcl b/GradeBook.tcl
index 5bff792..cb7ddf4 100755
--- a/GradeBook.tcl
+++ b/GradeBook.tcl
@@ -86,9 +86,29 @@ if { [file exists $dbfile] && ("$coursedbfname" ne "") } {
htmlHeader
puts "<body>"
sqlite3 db $dbfile
+
+ # we will do everything with in one transaction
+ # otherwise I see performance degradation on some computers
+ # when there are a lot if update statements
+ set eval_str [concat BEGIN TRANSACTION]
+ set err [catch {db eval $eval_str } errStat]
+ if { $err } {
+ htmlErrorMsg $errStat
+ dbg "the following error happen: $errStat" msg_level_critical
+ }
+
set permission_list [ AccessGroupRights db $user ]
htmlTop $permission_list
ChoseAction $action $permission_list $user
+
+ # ending transaction right before closing database
+ set eval_str [concat END TRANSACTION]
+ set err [catch {db eval $eval_str } errStat]
+ if { $err } {
+ htmlErrorMsg $errStat
+ dbg "the following error happen: $errStat" msg_level_critical
+ }
+
db close
} else {
htmlHeaderDBSelector