(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
This commit is contained in:
Dmitry S 2021-08-29 10:17:33 -04:00
parent 08d0ee65d1
commit dafdeee41c

View File

@ -342,7 +342,8 @@ 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
# 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