1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-12-24 14:17:58 +03:00

Have the rtree module set the estimatedCost output variable. Ticket #3312. (CVS 5649)

FossilOrigin-Name: 483932c4e08901a11b7ab671073fd0a048b10d66
This commit is contained in:
danielk1977
2008-09-01 12:46:59 +00:00
parent f5eccb6925
commit 865d4d4290
4 changed files with 130 additions and 9 deletions

View File

@@ -12,7 +12,7 @@
** This file contains code for implementations of the r-tree and r*-tree
** algorithms packaged as an SQLite virtual table module.
**
** $Id: rtree.c,v 1.7 2008/07/16 14:43:35 drh Exp $
** $Id: rtree.c,v 1.8 2008/09/01 12:47:00 danielk1977 Exp $
*/
#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_RTREE)
@@ -1116,6 +1116,13 @@ static int rtreeBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){
pIdxInfo->idxNum = 1;
pIdxInfo->aConstraintUsage[ii].argvIndex = 1;
pIdxInfo->aConstraintUsage[jj].omit = 1;
/* This strategy involves a two rowid lookups on an B-Tree structures
** and then a linear search of an R-Tree node. This should be
** considered almost as quick as a direct rowid lookup (for which
** sqlite uses an internal cost of 0.0).
*/
pIdxInfo->estimatedCost = 10.0;
return SQLITE_OK;
}
@@ -1169,6 +1176,8 @@ static int rtreeBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){
if( iIdx>0 && 0==(pIdxInfo->idxStr = sqlite3_mprintf("%s", zIdxStr)) ){
return SQLITE_NOMEM;
}
assert( iIdx>=0 );
pIdxInfo->estimatedCost = (2000000.0 / (double)(iIdx + 1));
return rc;
}