/ Check-in [69be427c]
Login

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

Overview
Comment:Another tweak to improve performance of fts5 prefix queries.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:69be427c864dc3de804ca3c5f1c6addcd33cd188
User & Date: dan 2015-10-19 17:43:24
Context
2015-10-19
20:49
Another optimization for fts5 prefix (and other) queries. check-in: 60a8bde0 user: dan tags: trunk
17:43
Another tweak to improve performance of fts5 prefix queries. check-in: 69be427c user: dan tags: trunk
15:59
Fix a problem in the fts5txt2db.tcl script causing it to fail when creating tables with more than 8 columns. check-in: 68ee426a user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Show Whitespace Changes Patch

Changes to ext/fts5/fts5_index.c.

  4107   4107       assert( fts5MultiIterEof(p, pMulti)==0 );
  4108   4108       assert( pSeg->nPos>0 );
  4109   4109       if( 0==fts5BufferGrow(&p->rc, pBuf, pSeg->nPos+9+9) ){
  4110   4110         int iSv1;
  4111   4111         int iSv2;
  4112   4112         int iData;
  4113   4113   
         4114  +      if( pSeg->iLeafOffset+pSeg->nPos<=pSeg->pLeaf->szLeaf 
         4115  +       && (pColset==0 || pColset->nCol==1)
         4116  +      ){
         4117  +        const u8 *pPos = &pSeg->pLeaf->p[pSeg->iLeafOffset];
         4118  +        int nPos;
         4119  +        if( pColset ){
         4120  +          nPos = fts5IndexExtractCol(&pPos, pSeg->nPos, pColset->aiCol[0]);
         4121  +          if( nPos==0 ) return 1;
         4122  +        }else{
         4123  +          nPos = pSeg->nPos;
         4124  +        }
         4125  +        assert( nPos>0 );
         4126  +        fts5BufferSafeAppendVarint(pBuf, iDelta);
         4127  +        fts5BufferSafeAppendVarint(pBuf, nPos*2);
         4128  +        fts5BufferSafeAppendBlob(pBuf, pPos, nPos);
         4129  +      }else{
  4114   4130         /* Append iDelta */
  4115   4131         iSv1 = pBuf->n;
  4116   4132         fts5BufferSafeAppendVarint(pBuf, iDelta);
  4117   4133   
  4118   4134         /* WRITEPOSLISTSIZE */
  4119   4135         iSv2 = pBuf->n;
  4120   4136         fts5BufferSafeAppendVarint(pBuf, pSeg->nPos*2);
  4121   4137         iData = pBuf->n;
  4122   4138   
  4123         -      if( pSeg->iLeafOffset+pSeg->nPos<=pSeg->pLeaf->szLeaf 
  4124         -       && (pColset==0 || pColset->nCol==1)
  4125         -      ){
  4126         -        const u8 *pPos = &pSeg->pLeaf->p[pSeg->iLeafOffset];
  4127         -        int nPos;
  4128         -        if( pColset ){
  4129         -          nPos = fts5IndexExtractCol(&pPos, pSeg->nPos, pColset->aiCol[0]);
  4130         -        }else{
  4131         -          nPos = pSeg->nPos;
  4132         -        }
  4133         -        fts5BufferSafeAppendBlob(pBuf, pPos, nPos);
  4134         -      }else{
  4135   4139           fts5SegiterPoslist(p, pSeg, pColset, pBuf);
  4136         -      }
  4137   4140   
  4138   4141         if( pColset ){
  4139   4142           int nActual = pBuf->n - iData;
  4140   4143           if( nActual!=pSeg->nPos ){
  4141   4144             if( nActual==0 ){
  4142   4145               pBuf->n = iSv1;
  4143   4146               return 1;
................................................................................
  4146   4149               while( iSv2<(iData-nReq) ){ pBuf->p[iSv2++] = 0x80; }
  4147   4150               sqlite3Fts5PutVarint(&pBuf->p[iSv2], nActual*2);
  4148   4151             }
  4149   4152           }
  4150   4153         }
  4151   4154       }
  4152   4155     }
         4156  +  }
  4153   4157   
  4154   4158     return 0;
  4155   4159   }
  4156   4160   
  4157   4161   static void fts5DoclistIterNext(Fts5DoclistIter *pIter){
  4158   4162     u8 *p = pIter->aPoslist + pIter->nSize + pIter->nPoslist;
  4159   4163