aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2011-07-13 18:31:10 +0000
committerdrh <drh@noemail.net>2011-07-13 18:31:10 +0000
commitbf4ec555fa99ce2968f8a309dab38e239bab6abc (patch)
tree5125d8f3d602352addacf85b5deac1b772ae73b8 /src
parentd0cdf012a2cfb309a57c1d3bf26f7045c7ce853f (diff)
downloadsqlite-bf4ec555fa99ce2968f8a309dab38e239bab6abc.tar.gz
sqlite-bf4ec555fa99ce2968f8a309dab38e239bab6abc.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/where.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/where.c b/src/where.c
index bb3bee357..d31223286 100644
--- a/src/where.c
+++ b/src/where.c
@@ -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 );