1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-22 20:22:44 +03:00

Do not try to use STAT2 to refine the row estimate of a query that

uses a unique or nearly-unique index.

FossilOrigin-Name: efffc49baf38698ed3de05d16b4261bf405d42d7
This commit is contained in:
drh
2011-07-13 18:31:10 +00:00
parent d0cdf012a2
commit bf4ec555fa
3 changed files with 10 additions and 9 deletions

View File

@@ -3111,12 +3111,13 @@ static void bestBtreeIndex(
}
#ifdef SQLITE_ENABLE_STAT2
/* If the constraint is of the form x=VALUE and histogram
/* If the constraint is of the form x=VALUE or x IN (E1,E2,...)
** and we do not think that values of x are unique and if histogram
** data is available for column x, then it might be possible
** to get a better estimate on the number of rows based on
** VALUE and how common that value is according to the histogram.
*/
if( nRow>(double)1 && nEq==1 && pFirstTerm!=0 ){
if( nRow>(double)1 && nEq==1 && pFirstTerm!=0 && aiRowEst[1]>1 ){
if( pFirstTerm->eOperator & (WO_EQ|WO_ISNULL) ){
testcase( pFirstTerm->eOperator==WO_EQ );
testcase( pFirstTerm->eOperator==WO_ISNULL );