From 52846b8e6866e08875b77325d560f7ff39bc7113 Mon Sep 17 00:00:00 2001 From: prculley Date: Thu, 5 Jan 2017 14:00:36 -0600 Subject: [PATCH] bug 9877; fix performace with people tree view and some filters When using deep relationship filters on the person tree view with a large tree, the tree redraw can take a long time (hours). The DeepRelationshipPathBetween 'prepare' method was getting called for every person in the preceding filter. And that it also ran through every person in the db within the prepare method. Resulting in time as a square function of number of people. Change view code so that 'prepare' method is called once, and 'apply' method is called once with list of handles to scan, rather than both called once per handle. --- gramps/gui/views/treemodels/treebasemodel.py | 22 ++++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/gramps/gui/views/treemodels/treebasemodel.py b/gramps/gui/views/treemodels/treebasemodel.py index 7b1c3d2ec..b0ff4505f 100644 --- a/gramps/gui/views/treemodels/treebasemodel.py +++ b/gramps/gui/views/treemodels/treebasemodel.py @@ -591,16 +591,20 @@ class TreeBaseModel(GObject.GObject, Gtk.TreeModel, BaseModel): pmon.add_op(status_ppl) self.__total += items + assert not skip + if dfilter: + for handle in dfilter.apply(self.db, + cb_progress=status_ppl.heartbeat): + data = data_map(handle) + add_func(handle, data) + self.__displayed += 1 + else: + with gen_cursor() as cursor: + for handle, data in cursor: + status_ppl.heartbeat() + add_func(handle, data) + self.__displayed += 1 - with gen_cursor() as cursor: - for handle, data in cursor: - if not isinstance(handle, str): - handle = handle.decode('utf-8') - status_ppl.heartbeat() - if not handle in skip: - if not dfilter or dfilter.match(handle, self.db): - add_func(handle, data) - self.__displayed += 1 status_ppl.end() status.end()