Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimise Postgres post processing to speedup process #75

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion bin/load_db_scxa_analytics.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ time sed "s/<EXP-ACCESSION>/$lc_exp_acc/g" $postgres_scripts_dir/04-build_pk.sql
psql -v ON_ERROR_STOP=1 $dbConnection

# Post-process partition table
sed "s/<EXP-ACCESSION>/$lc_exp_acc/g" $postgres_scripts_dir/05-post_processing.sql.template | \
sed "s/<EXP-ACCESSION>/$lc_exp_acc/g" $postgres_scripts_dir/05-01-post_processing.sql.template | \
sed "s/<EXP-ACC-UC>/$EXP_ID/g" | \
psql -v ON_ERROR_STOP=1 $dbConnection

# Post-process partition table
sed "s/<EXP-ACCESSION>/$lc_exp_acc/g" $postgres_scripts_dir/05-02-post_processing.sql.template | \
sed "s/<EXP-ACC-UC>/$EXP_ID/g" | \
psql -v ON_ERROR_STOP=1 $dbConnection

Expand Down
8 changes: 8 additions & 0 deletions postgres_routines/05-01-post_processing.sql.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
This script performs a group of post-load tasks:
- cluster the partition tables on primary key (optional) -> blocking op
- collect statistics on the partition tables (mandatory)
*/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
SET maintenance_work_mem = '16GB';

CLUSTER scxa_analytics_<EXP-ACCESSION> USING scxa_analytics_<EXP-ACCESSION>_pk;
ANALYZE scxa_analytics_<EXP-ACCESSION>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ANALYZE scxa_analytics_<EXP-ACCESSION>;
ANALYZE scxa_analytics_<EXP-ACCESSION>;
RESET maintenance_work_mem ;

8 changes: 8 additions & 0 deletions postgres_routines/05-02-post_processing.sql.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
This script performs a group of post-load tasks:
- re-enable autovacuum (mandatory)
- add a check constraint on the partition value (mandatory)
*/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Increase memory for maintenance, current one used is 256MB

Suggested change
SET maintenance_work_mem = '16GB';

alter table scxa_analytics_<EXP-ACCESSION> SET (autovacuum_enabled = true, toast.autovacuum_enabled = true) add constraint check_e_ebi_<EXP-ACCESSION> check (experiment_accession='<EXP-ACC-UC>');
RESET maintenance_work_mem ;
13 changes: 0 additions & 13 deletions postgres_routines/05-post_processing.sql.template

This file was deleted.

Loading