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

Optimization for "SELECT min(x) FROM tbl" where "x" is indexed and NOT NULL. This also allows similar queries on NOT NULL virtual table columns to be optimized.

FossilOrigin-Name: 59726777934e201d94e99ca693f0fda4ebfb1c7883d0258ce542f63f9924c28c
This commit is contained in:
dan
2020-02-27 15:07:16 +00:00
parent 47a60d4518
commit 67e2bb92df
4 changed files with 65 additions and 9 deletions

View File

@@ -4477,7 +4477,9 @@ static u8 minMaxQuery(sqlite3 *db, Expr *pFunc, ExprList **ppMinMax){
zFunc = pFunc->u.zToken;
if( sqlite3StrICmp(zFunc, "min")==0 ){
eRet = WHERE_ORDERBY_MIN;
sortFlags = KEYINFO_ORDER_BIGNULL;
if( sqlite3ExprCanBeNull(pEList->a[0].pExpr) ){
sortFlags = KEYINFO_ORDER_BIGNULL;
}
}else if( sqlite3StrICmp(zFunc, "max")==0 ){
eRet = WHERE_ORDERBY_MAX;
sortFlags = KEYINFO_ORDER_DESC;