mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
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
This commit is contained in:
@ -2221,16 +2221,32 @@ 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<nCell; iCell++){
|
||||
RtreeCell cell;
|
||||
nodeGetCell(pRtree, pNode, iCell, &cell);
|
||||
if( cellContains(pRtree, &cell, pCell) ){
|
||||
RtreeDValue area = cellArea(pRtree, &cell);
|
||||
if( bFound==0 || area<fMinArea ){
|
||||
iBest = cell.iRowid;
|
||||
fMinArea = area;
|
||||
bFound = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( !bFound ){
|
||||
/* No cells of pNode will completely contain pCell. So pick the
|
||||
** cell of pNode that grows by the least amount when pCell is added.
|
||||
** Break ties by selecting the smaller cell.
|
||||
*/
|
||||
for(iCell=0; iCell<nCell; iCell++){
|
||||
RtreeCell cell;
|
||||
@ -2249,6 +2265,7 @@ static int ChooseLeaf(
|
||||
iBest = cell.iRowid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rc = nodeAcquire(pRtree, iBest, pNode, &pChild);
|
||||
nodeRelease(pRtree, pNode);
|
||||
|
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
||||
C Reduce\sthe\snumber\sof\scalls\sto\scellArea()\sin\sthe\sChooseLeaf()\salgorithm\sof\nrtree.
|
||||
D 2023-09-13T12:06:02.688
|
||||
C In\sthe\sChooseLeaf\salgorithm\sof\sRTREE,\sdo\san\sinitial\spass\sthrough\sthe\scells\nof\sa\snode\slooking\sfor\ssolutions\sthat\sinvolve\sno\scell\senlargement.\s\sOnly\slook\nfor\sthe\sminimum\scell\senlargement\sif\sthe\senlargement\sis\snon-zero\sfor\sall\scells.\nThis\sresults\sin\sa\sperformance\simprovement\sby\sreducing\sthe\snumber\sof\scalls\nto\scellUnion().
|
||||
D 2023-09-13T13:12:08.325
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||
@ -471,7 +471,7 @@ F ext/repair/test/checkindex01.test b530f141413b587c9eb78ff734de6bb79bc3515c3350
|
||||
F ext/repair/test/test.tcl 686d76d888dffd021f64260abf29a55c57b2cedfa7fc69150b42b1d6119aac3c
|
||||
F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761
|
||||
F ext/rtree/geopoly.c 971e0b5bd9adaf0811feb8c0842a310811159da10319eb0e74fdb42bf26b99ca
|
||||
F ext/rtree/rtree.c 2cf6c6a643bf7bd0eca116b37d81c65ad2407136ee523729050cb56da0e1651a
|
||||
F ext/rtree/rtree.c 14e745969e69f128b27c3106318fd9bb5f87eb00c5bfdd5ccbb60a1872deb5b7
|
||||
F ext/rtree/rtree.h 4a690463901cb5e6127cf05eb8e642f127012fd5003830dbc974eca5802d9412
|
||||
F ext/rtree/rtree1.test 877d40b8b61b1f88cec9d4dc0ff8334f5b05299fac12a35141532e2881860e9d
|
||||
F ext/rtree/rtree2.test 9d9deddbb16fd0c30c36e6b4fdc3ee3132d765567f0f9432ee71e1303d32603d
|
||||
@ -2119,8 +2119,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P fb2e4a8067edc29ba64973820f265b21dfee0d32f4d675d32100d5eef93c2830
|
||||
R 50c424399f759c0884768065cbc409ef
|
||||
P c633fe6be0edc07a0aa1ac819d58b6c629b7c95b47b63516ae1b0a937f6a2b89
|
||||
R c022f3599d3f41d22b9b1469e98905ec
|
||||
U drh
|
||||
Z ac2eaf32235b1d74f19a79e1691a60ae
|
||||
Z 4cc63f132e0276d1f1f57289f0e4433b
|
||||
# Remove this line to create a well-formed Fossil manifest.
|
||||
|
@ -1 +1 @@
|
||||
c633fe6be0edc07a0aa1ac819d58b6c629b7c95b47b63516ae1b0a937f6a2b89
|
||||
59f0e239d19393190911ea3bd89b5a24be0d85d64ccf51906efc9537ad5d7298
|
Reference in New Issue
Block a user