From dafdeee41c004dcc8727200dd84b20101ba5774f Mon Sep 17 00:00:00 2001 From: Dmitry S Date: Sun, 29 Aug 2021 10:17:33 -0400 Subject: [PATCH] (core) Optimize overly-cautious column replacing Summary: Replacing a column leads to an unnecessary recalculation, and was happening on every schema change. This is particularly noticeble for large docs, especially for imports when each column's addition is a schema change in itself, so recalculation of summary table groupings were happening many times. Test Plan: Existing tests should pass. No tests yet for avoiding recalculation, but would be nice! Reviewers: alexmojaki Reviewed By: alexmojaki Subscribers: paulfitz Differential Revision: https://phab.getgrist.com/D3005 --- sandbox/grist/table.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sandbox/grist/table.py b/sandbox/grist/table.py index 975da063..ceca65fd 100644 --- a/sandbox/grist/table.py +++ b/sandbox/grist/table.py @@ -342,8 +342,9 @@ class Table(object): _updateSummary.is_private = True col_id = summary_table._summary_helper_col_id if self.has_column(col_id): - # Column type may have changed, replace completely - self.delete_column(self.get_column(col_id)) + # If type changed between Reference/ReferenceList, replace completely. + if type(self.get_column(col_id).type_obj) != type(_updateSummary.grist_type): + self.delete_column(self.get_column(col_id)) col_obj = self._create_or_update_col(col_id, _updateSummary) self._special_cols[col_id] = col_obj self.all_columns[col_id] = col_obj