SurveyJSON size reduction/optimization
SurveyJSON was storing a lot of redundant information (every setting on every single section/question/answer, which, in most cases, will simply take on the default values). This was bloating the surveyJSON property in the db, and equally as importantly, slowing down Survey because it had to do a lot of JSON parsing on the serialised surveyJSON object. We now factor out and store the current section/question/answer defaults along with the surveyJSON data itself, which means that we only needs to store properties that differ from the defaults. This results is a massive reduction in the size of the serialized surveyJSON stored in the database, as well as a speed-up in json parsing time. The compression/uncompression happens transparently to the rest of Survey.
This commit is contained in:
parent
d26ce5b447
commit
cbc308c55a
4 changed files with 192 additions and 21 deletions
|
|
@ -36,6 +36,7 @@ my $session = start(); # this line required
|
|||
setDefaultIcalInterval($session);
|
||||
makeSurveyResponsesVersionAware($session);
|
||||
addShipperGroupToUse($session);
|
||||
shrinkSurveyJSON($session);
|
||||
|
||||
finish($session); # this line required
|
||||
|
||||
|
|
@ -95,6 +96,23 @@ END_SQL
|
|||
print "DONE!\n" unless $quiet;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
sub shrinkSurveyJSON {
|
||||
my $session = shift;
|
||||
print "\tCompressing surveyJSON column in Survey table (this may take some time)... " unless $quiet;
|
||||
my $sth = $session->db->read('select assetId, revisionDate from Survey');
|
||||
use WebGUI::Asset::Wobject::Survey;
|
||||
while (my ($assetId, $revision) = $sth->array) {
|
||||
my $survey = WebGUI::Asset->new($session, $assetId, 'WebGUI::Asset::Wobject::Survey', $revision);
|
||||
$survey->persistSurveyJSON;
|
||||
}
|
||||
print "DONE!\n" unless $quiet;
|
||||
|
||||
print "\tOptimizing Survey table... " unless $quiet;
|
||||
$session->db->write('optimize table Survey');
|
||||
print "DONE!\n" unless $quiet;
|
||||
}
|
||||
|
||||
|
||||
# -------------- DO NOT EDIT BELOW THIS LINE --------------------------------
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue