From: drh <> Date: Wed, 13 Sep 2023 13:12:08 +0000 (+0000) Subject: In the ChooseLeaf algorithm of RTREE, do an initial pass through the cells X-Git-Tag: version-3.44.0~193^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cdae00b3e8e4b1513276e746cad21cacaf056eff;p=thirdparty%2Fsqlite.git In the ChooseLeaf algorithm of RTREE, do an initial pass through the cells of a node looking for solutions that involve no cell enlargement. Only look for the minimum cell enlargement if the enlargement is non-zero for all cells. This results in a performance improvement by reducing the number of calls to cellUnion(). FossilOrigin-Name: 59f0e239d19393190911ea3bd89b5a24be0d85d64ccf51906efc9537ad5d7298 --- diff --git a/ext/rtree/rtree.c b/ext/rtree/rtree.c index b2e8b3b65b..5a1450801f 100644 --- a/ext/rtree/rtree.c +++ b/ext/rtree/rtree.c @@ -2221,32 +2221,49 @@ static int ChooseLeaf( for(ii=0; rc==SQLITE_OK && ii<(pRtree->iDepth-iHeight); ii++){ int iCell; sqlite3_int64 iBest = 0; - + int bFound = 0; RtreeDValue fMinGrowth = RTREE_ZERO; RtreeDValue fMinArea = RTREE_ZERO; - int nCell = NCELL(pNode); RtreeNode *pChild = 0; - /* Select the child node which will be enlarged the least if pCell - ** is inserted into it. Resolve ties by choosing the entry with - ** the smallest area. + /* First check to see if there is are any cells in pNode that completely + ** contains pCell. If two or more cells in pNode completely contain pCell + ** then pick the smallest. */ for(iCell=0; iCell