From 19aaf96ac09601d89471f6defd1948c69c4e6b70 Mon Sep 17 00:00:00 2001 From: John van Breda Date: Sat, 12 Nov 2016 16:57:16 +0000 Subject: [PATCH] Switched to cache_occurrences_functional Better performance if all filtering done in one table. --- application/helpers/report_standard_params_occurrences.php | 5 +---- .../201611121607_cache_occurrences_id_diff.sql | 4 ++++ ...a.sql => 201611121607_cache_occurrences_id_diff_data.sql} | 4 ++-- .../201611121607_cache_taxa_taxon_lists_id_diff.sql | 4 ---- 4 files changed, 7 insertions(+), 10 deletions(-) create mode 100644 modules/cache_builder/db/version_1_15_0/201611121607_cache_occurrences_id_diff.sql rename modules/cache_builder/db/version_1_15_0/{201611121607_cache_taxa_taxon_lists_id_diff_data.sql => 201611121607_cache_occurrences_id_diff_data.sql} (62%) delete mode 100644 modules/cache_builder/db/version_1_15_0/201611121607_cache_taxa_taxon_lists_id_diff.sql diff --git a/application/helpers/report_standard_params_occurrences.php b/application/helpers/report_standard_params_occurrences.php index 26da268d37..8ee424b6ff 100644 --- a/application/helpers/report_standard_params_occurrences.php +++ b/application/helpers/report_standard_params_occurrences.php @@ -395,12 +395,9 @@ public static function getParameters() { ), 'identification_difficulty' => array('datatype'=>'integer', 'default'=>'', 'display'=>'Identification difficulty', 'description'=>'Identification difficulty on a scale of 1 to 5', - 'joins' => array( - array('value'=>'', 'operator'=>'', 'standard_join'=>'prefcttl') - ), 'wheres' => array( array('value'=>'', 'operator'=>'', - 'sql'=>"coalesce(cttl.identification_difficulty, 0) #identification_difficulty_op# #identification_difficulty#") + 'sql'=>"coalesce(o.identification_difficulty, 0) #identification_difficulty_op# #identification_difficulty#") ) ), ); diff --git a/modules/cache_builder/db/version_1_15_0/201611121607_cache_occurrences_id_diff.sql b/modules/cache_builder/db/version_1_15_0/201611121607_cache_occurrences_id_diff.sql new file mode 100644 index 0000000000..ce20ccbec5 --- /dev/null +++ b/modules/cache_builder/db/version_1_15_0/201611121607_cache_occurrences_id_diff.sql @@ -0,0 +1,4 @@ +ALTER TABLE cache_occurrences_functional ADD COLUMN identification_difficulty integer; + +COMMENT ON COLUMN cache_occurrences_functional.identification_difficulty IS + 'Identification difficulty assigned by the data_cleaner module, on a scale from 1 (easy) to 5 (difficult)'; \ No newline at end of file diff --git a/modules/cache_builder/db/version_1_15_0/201611121607_cache_taxa_taxon_lists_id_diff_data.sql b/modules/cache_builder/db/version_1_15_0/201611121607_cache_occurrences_id_diff_data.sql similarity index 62% rename from modules/cache_builder/db/version_1_15_0/201611121607_cache_taxa_taxon_lists_id_diff_data.sql rename to modules/cache_builder/db/version_1_15_0/201611121607_cache_occurrences_id_diff_data.sql index 008cfa91d3..86389c9d0d 100644 --- a/modules/cache_builder/db/version_1_15_0/201611121607_cache_taxa_taxon_lists_id_diff_data.sql +++ b/modules/cache_builder/db/version_1_15_0/201611121607_cache_occurrences_id_diff_data.sql @@ -1,8 +1,8 @@ -- #slow script# -update cache_taxa_taxon_lists cttl +update cache_occurrences_functional o set identification_difficulty=vrd.value::integer from verification_rule_data vrd join verification_rules vr on vr.id=vrd.verification_rule_id and vr.deleted=false and vr.test_type='IdentificationDifficulty' -where vrd.header_name='Data' and upper(vrd.key)=cttl.external_key and vrd.deleted=false; \ No newline at end of file +where vrd.header_name='Data' and upper(vrd.key)=o.taxa_taxon_list_external_key and vrd.deleted=false; \ No newline at end of file diff --git a/modules/cache_builder/db/version_1_15_0/201611121607_cache_taxa_taxon_lists_id_diff.sql b/modules/cache_builder/db/version_1_15_0/201611121607_cache_taxa_taxon_lists_id_diff.sql deleted file mode 100644 index 5fe17cef27..0000000000 --- a/modules/cache_builder/db/version_1_15_0/201611121607_cache_taxa_taxon_lists_id_diff.sql +++ /dev/null @@ -1,4 +0,0 @@ -ALTER TABLE cache_taxa_taxon_lists ADD COLUMN identification_difficulty integer; - -COMMENT ON COLUMN cache_taxa_taxon_lists.identification_difficulty IS - 'Identification difficulty assigned by the data_cleaner module, on a scale from 1 (easy) to 5 (difficult)'; \ No newline at end of file