SQLite

Check-in [746b183683]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:This hack illustrates how to use the VDBE_PROFILE mechanism to show which bytecode operators are using resources other than time. In this case, the number of loops through the binary search code in sqlite3BtreeMovetoUnpacked() is measured, for the purpose of helping to identify unnecessary btree searches.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | vdbe-aux-perf
Files: files | file ages | folders
SHA1: 746b1836834914627d97369690b9596d80235a35
User & Date: drh 2017-01-07 00:42:57.449
Context
2017-01-09
20:57
Merge latest changes from trunk, and also move the perf-counter into the inner loop of sqlite3BtreeMovetoUnpacked(). (Leaf check-in: ff9eab9587 user: drh tags: vdbe-aux-perf)
2017-01-07
00:42
This hack illustrates how to use the VDBE_PROFILE mechanism to show which bytecode operators are using resources other than time. In this case, the number of loops through the binary search code in sqlite3BtreeMovetoUnpacked() is measured, for the purpose of helping to identify unnecessary btree searches. (check-in: 746b183683 user: drh tags: vdbe-aux-perf)
2017-01-06
13:49
Ensure that "PRAGMA case_sensitive_like" and "PRAGMA shrink_memory" set the number of output columns to 0 (as they are statements that return no data). (check-in: 6696cd1878 user: dan tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/btree.c.
5120
5121
5122
5123
5124
5125
5126

5127
5128
5129
5130
5131
5132
5133
  assert( pCur->apPage[0]->intKey==pCur->curIntKey );
  assert( pCur->curIntKey || pIdxKey );
  for(;;){
    int lwr, upr, idx, c;
    Pgno chldPg;
    MemPage *pPage = pCur->apPage[pCur->iPage];
    u8 *pCell;                          /* Pointer to current cell in pPage */


    /* pPage->nCell must be greater than zero. If this is the root-page
    ** the cursor would have been INVALID above and this for(;;) loop
    ** not run. If this is not the root-page, then the moveToChild() routine
    ** would have already detected db corruption. Similarly, pPage must
    ** be the right kind (index or table) of b-tree page. Otherwise
    ** a moveToChild() or moveToRoot() call would have detected corruption.  */







>







5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
  assert( pCur->apPage[0]->intKey==pCur->curIntKey );
  assert( pCur->curIntKey || pIdxKey );
  for(;;){
    int lwr, upr, idx, c;
    Pgno chldPg;
    MemPage *pPage = pCur->apPage[pCur->iPage];
    u8 *pCell;                          /* Pointer to current cell in pPage */
sqlite3PerfCnt++;

    /* pPage->nCell must be greater than zero. If this is the root-page
    ** the cursor would have been INVALID above and this for(;;) loop
    ** not run. If this is not the root-page, then the moveToChild() routine
    ** would have already detected db corruption. Similarly, pPage must
    ** be the right kind (index or table) of b-tree page. Otherwise
    ** a moveToChild() or moveToRoot() call would have detected corruption.  */
Changes to src/sqliteInt.h.
4316
4317
4318
4319
4320
4321
4322


4323
4324
#endif

int sqlite3ExprVectorSize(Expr *pExpr);
int sqlite3ExprIsVector(Expr *pExpr);
Expr *sqlite3VectorFieldSubexpr(Expr*, int);
Expr *sqlite3ExprForVectorField(Parse*,Expr*,int);
void sqlite3VectorErrorMsg(Parse*, Expr*);



#endif /* SQLITEINT_H */







>
>


4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
#endif

int sqlite3ExprVectorSize(Expr *pExpr);
int sqlite3ExprIsVector(Expr *pExpr);
Expr *sqlite3VectorFieldSubexpr(Expr*, int);
Expr *sqlite3ExprForVectorField(Parse*,Expr*,int);
void sqlite3VectorErrorMsg(Parse*, Expr*);

sqlite3_uint64 sqlite3PerfCnt;

#endif /* SQLITEINT_H */
Changes to src/vdbe.c.
502
503
504
505
506
507
508
509

510
511
512
513
514
515
516

#ifdef VDBE_PROFILE

/* 
** hwtime.h contains inline assembler code for implementing 
** high-performance timing routines.
*/
#include "hwtime.h"


#endif

#ifndef NDEBUG
/*
** This function is only called from within an assert() expression. It
** checks that the sqlite3.nTransaction variable is correctly set to







|
>







502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517

#ifdef VDBE_PROFILE

/* 
** hwtime.h contains inline assembler code for implementing 
** high-performance timing routines.
*/
/*#include "hwtime.h"*/
#define sqlite3Hwtime(x) sqlite3PerfCnt

#endif

#ifndef NDEBUG
/*
** This function is only called from within an assert() expression. It
** checks that the sqlite3.nTransaction variable is correctly set to