/ Check-in [4577fea5]
Login

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

Overview
Comment:Avoid adding INTEGER PRIMARY KEY columns to candidate indexes.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | schemalint
Files: files | file ages | folders
SHA3-256: 4577fea5cd9d91ea241e9be82797ca1a4447f536e1e4b78a4a569aeb52e78fcb
User & Date: dan 2017-04-20 16:18:43
Context
2017-04-20
17:03
Avoid creating a temp table in the user database in the sqlite3_expert code. check-in: 4e366996 user: dan tags: schemalint
16:18
Avoid adding INTEGER PRIMARY KEY columns to candidate indexes. check-in: 4577fea5 user: dan tags: schemalint
09:54
Add an option to generate stat1 data based on a subset of the user database table contents to sqlite3_expert. check-in: c69c3e21 user: dan tags: schemalint
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/expert/sqlite3expert.c.

   385    385       pScan->pTab = p->pTab;
   386    386       pScan->pNextScan = p->pExpert->pScan;
   387    387       p->pExpert->pScan = pScan;
   388    388   
   389    389       /* Add the constraints to the IdxScan object */
   390    390       for(i=0; i<pIdxInfo->nConstraint; i++){
   391    391         struct sqlite3_index_constraint *pCons = &pIdxInfo->aConstraint[i];
   392         -      if( pCons->usable && pCons->iColumn>=0 && (pCons->op & opmask) ){
          392  +      if( pCons->usable 
          393  +       && pCons->iColumn>=0 
          394  +       && p->pTab->aCol[pCons->iColumn].iPk==0
          395  +       && (pCons->op & opmask) 
          396  +      ){
   393    397           IdxConstraint *pNew;
   394    398           const char *zColl = sqlite3_vtab_collation(dbv, i);
   395    399           pNew = idxNewConstraint(&rc, zColl);
   396    400           if( pNew ){
   397    401             pNew->iCol = pCons->iColumn;
   398    402             if( pCons->op==SQLITE_INDEX_CONSTRAINT_EQ ){
   399    403               pNew->pNext = pScan->pEq;
................................................................................
   553    557   ){
   554    558     sqlite3_stmt *p1 = 0;
   555    559     int nCol = 0;
   556    560     int nTab = strlen(zTab);
   557    561     int nByte = sizeof(IdxTable) + nTab + 1;
   558    562     IdxTable *pNew = 0;
   559    563     int rc, rc2;
   560         -  char *pCsr;
          564  +  char *pCsr = 0;
   561    565   
   562    566     rc = idxPrintfPrepareStmt(db, &p1, pzErrmsg, "PRAGMA table_info=%Q", zTab);
   563    567     while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(p1) ){
   564    568       const char *zCol = (const char*)sqlite3_column_text(p1, 1);
   565    569       nByte += 1 + strlen(zCol);
   566    570       rc = sqlite3_table_column_metadata(
   567    571           db, "main", zTab, zCol, 0, &zCol, 0, 0, 0