/ 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 Ignore Whitespace 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         -      /* Append iDelta */
  4115         -      iSv1 = pBuf->n;
  4116         -      fts5BufferSafeAppendVarint(pBuf, iDelta);
  4117         -
  4118         -      /* WRITEPOSLISTSIZE */
  4119         -      iSv2 = pBuf->n;
  4120         -      fts5BufferSafeAppendVarint(pBuf, pSeg->nPos*2);
  4121         -      iData = pBuf->n;
  4122         -
  4123   4114         if( pSeg->iLeafOffset+pSeg->nPos<=pSeg->pLeaf->szLeaf 
  4124   4115          && (pColset==0 || pColset->nCol==1)
  4125   4116         ){
  4126   4117           const u8 *pPos = &pSeg->pLeaf->p[pSeg->iLeafOffset];
  4127   4118           int nPos;
  4128   4119           if( pColset ){
  4129   4120             nPos = fts5IndexExtractCol(&pPos, pSeg->nPos, pColset->aiCol[0]);
         4121  +          if( nPos==0 ) return 1;
  4130   4122           }else{
  4131   4123             nPos = pSeg->nPos;
  4132   4124           }
         4125  +        assert( nPos>0 );
         4126  +        fts5BufferSafeAppendVarint(pBuf, iDelta);
         4127  +        fts5BufferSafeAppendVarint(pBuf, nPos*2);
  4133   4128           fts5BufferSafeAppendBlob(pBuf, pPos, nPos);
  4134   4129         }else{
         4130  +        /* Append iDelta */
         4131  +        iSv1 = pBuf->n;
         4132  +        fts5BufferSafeAppendVarint(pBuf, iDelta);
         4133  +
         4134  +        /* WRITEPOSLISTSIZE */
         4135  +        iSv2 = pBuf->n;
         4136  +        fts5BufferSafeAppendVarint(pBuf, pSeg->nPos*2);
         4137  +        iData = pBuf->n;
         4138  +
  4135   4139           fts5SegiterPoslist(p, pSeg, pColset, pBuf);
  4136         -      }
  4137   4140   
  4138         -      if( pColset ){
  4139         -        int nActual = pBuf->n - iData;
  4140         -        if( nActual!=pSeg->nPos ){
  4141         -          if( nActual==0 ){
  4142         -            pBuf->n = iSv1;
  4143         -            return 1;
  4144         -          }else{
  4145         -            int nReq = sqlite3Fts5GetVarintLen((u32)(nActual*2));
  4146         -            while( iSv2<(iData-nReq) ){ pBuf->p[iSv2++] = 0x80; }
  4147         -            sqlite3Fts5PutVarint(&pBuf->p[iSv2], nActual*2);
         4141  +        if( pColset ){
         4142  +          int nActual = pBuf->n - iData;
         4143  +          if( nActual!=pSeg->nPos ){
         4144  +            if( nActual==0 ){
         4145  +              pBuf->n = iSv1;
         4146  +              return 1;
         4147  +            }else{
         4148  +              int nReq = sqlite3Fts5GetVarintLen((u32)(nActual*2));
         4149  +              while( iSv2<(iData-nReq) ){ pBuf->p[iSv2++] = 0x80; }
         4150  +              sqlite3Fts5PutVarint(&pBuf->p[iSv2], nActual*2);
         4151  +            }
  4148   4152             }
  4149   4153           }
  4150   4154         }
  4151   4155       }
  4152   4156     }
  4153   4157   
  4154   4158     return 0;