metasfresh-webui-api-legacy icon indicating copy to clipboard operation
metasfresh-webui-api-legacy copied to clipboard

t_query_selection grows huge when importing products or partners massively

Open metasnw opened this issue 7 years ago • 3 comments

Is this a bug or feature request?

bug

What is the current behavior?

when you import 30K products or 30K partners the table will grow 60-120 GB

Which are the steps to reproduce?

  1. import into i_product or i_partner via sql
  2. run the process to import from webui window import-product or import-partner

problems:

  1. disk space
  2. serverload is pretty high

What is the expected or desired behavior?

should work lean as before as I dont recall this behaviour on imports one a while ago

metasnw avatar Feb 18 '18 19:02 metasnw

Configuration

  • metasfresh.query.clearQuerySelectionRateInSeconds (default: 60)

teosarca avatar Feb 20 '18 13:02 teosarca

suggestion: also take a look at the vacuum settings of metasfresh-db

General setting in postgresql.conf

autovacuum_vacuum_scale_factor = 0.05
autovacuum_analyze_scale_factor = 0.05

Further reading: https://medium.com/contactually-engineering/postgres-at-scale-query-performance-and-autovacuuming-for-large-tables-d7e8ad40b16b

In particualr for this table, we might want to be more strict:

ALTER TABLE public.t_query_selection SET (autovacuum_vacuum_scale_factor = 0);
ALTER TABLE public.t_query_selection SET (autovacuum_vacuum_threshold = 10000);

Further infos: https://blog.2ndquadrant.com/autovacuum-tuning-basics/

metas-ts avatar Feb 20 '18 14:02 metas-ts

WRT changing the settings, this might be a good approach: https://stackoverflow.com/a/42508925/1012103

AFAIU we could put those SQLs into our create_db.sh in metasfresh-docker

metas-ts avatar Feb 20 '18 22:02 metas-ts