1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-27 20:41:58 +03:00

Scan an index instead of a table for "SELECT count(*) FROM <tbl>" queries. Because an index is usually smaller than a table on disk, this saves some IO. (CVS 6315)

FossilOrigin-Name: 294ba6f743c9132dce0e73da480bd3c2071e7239
This commit is contained in:
danielk1977
2009-02-23 17:33:49 +00:00
parent 699b3d4f89
commit e2d7b24d08
9 changed files with 82 additions and 33 deletions

View File

@ -14,7 +14,7 @@
** resolve all identifiers by associating them with a particular
** table and column.
**
** $Id: resolve.c,v 1.16 2009/02/19 14:39:25 danielk1977 Exp $
** $Id: resolve.c,v 1.17 2009/02/23 17:33:50 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <stdlib.h>
@ -347,14 +347,18 @@ static int lookupName(
** column number is greater than the number of bits in the bitmask
** then set the high-order bit of the bitmask.
*/
if( pExpr->iColumn>=0 && pMatch!=0 ){
int n = pExpr->iColumn;
testcase( n==BMS-1 );
if( n>=BMS ){
n = BMS-1;
if( pMatch ){
if( pExpr->iColumn>=0 ){
int n = pExpr->iColumn;
testcase( n==BMS-1 );
if( n>=BMS ){
n = BMS-1;
}
assert( pMatch->iCursor==pExpr->iTable );
pMatch->colUsed |= ((Bitmask)1)<<n;
}else{
pMatch->usesRowid = 1;
}
assert( pMatch->iCursor==pExpr->iTable );
pMatch->colUsed |= ((Bitmask)1)<<n;
}
lookupname_end: