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
|
|
@ -17,6 +17,7 @@
|
|||
- fixed #10551: paypal (link to section of paypal website to enter in WebGUI information)
|
||||
- fixed #10550: shipping plugins have no privileges
|
||||
- fixed: Add progress bars for paste and edit branch.
|
||||
- fixed: SurveyJSON database bloating
|
||||
|
||||
7.7.10
|
||||
- Made a change to LDAP auth that adds an OR to that query so that it also searches for a row with fieldData REGEXP '^uid=(value-from-ldap-directory-server),'. (Wes Morgan)
|
||||
|
|
|
|||
|
|
@ -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