diff --git a/src/django_clickhouse/clickhouse_models.py b/src/django_clickhouse/clickhouse_models.py index 73f2e32..2d11d37 100644 --- a/src/django_clickhouse/clickhouse_models.py +++ b/src/django_clickhouse/clickhouse_models.py @@ -234,7 +234,9 @@ class ClickHouseModel(with_metaclass(ClickHouseModelMeta, InfiModel)): if import_objects: with statsd.timer(statsd_key.format('steps.get_insert_batch')): - batch = cls.get_insert_batch(import_objects) + # NOTE I don't use generator pattern here, as it move all time into insert. + # That makes hard to understand where real problem is in monitoring + batch = tuple(cls.get_insert_batch(import_objects)) with statsd.timer(statsd_key.format('steps.insert')): cls.insert_batch(batch) @@ -312,7 +314,9 @@ class ClickHouseMultiModel(ClickHouseModel): def _sub_model_func(model_cls): model_statsd_key = "%s.sync.%s.{0}" % (config.STATSD_PREFIX, model_cls.__name__) with statsd.timer(model_statsd_key.format('steps.get_insert_batch')): - batch = model_cls.get_insert_batch(import_objects) + # NOTE I don't use generator pattern here, as it move all time into insert. + # That makes hard to understand where real problem is in monitoring + batch = tuple(model_cls.get_insert_batch(import_objects)) return model_cls, batch res = exec_multi_arg_func(_sub_model_func, cls.sub_models, threads_count=len(cls.sub_models)) diff --git a/src/django_clickhouse/engines.py b/src/django_clickhouse/engines.py index 4b59389..46cf26b 100644 --- a/src/django_clickhouse/engines.py +++ b/src/django_clickhouse/engines.py @@ -139,7 +139,9 @@ class CollapsingMergeTree(InsertOnlyEngineMixin, infi_engines.CollapsingMergeTre statsd_key = "%s.sync.%s.steps.get_final_versions" % (config.STATSD_PREFIX, model_cls.__name__) with statsd.timer(statsd_key): - old_objs = self.get_final_versions(model_cls, new_objs) + # NOTE I don't use generator pattern here, as it move all time into insert. + # That makes hard to understand where real problem is in monitoring + old_objs = tuple(self.get_final_versions(model_cls, new_objs)) # -1 sign has been set get_final_versions() old_objs_versions = {}