/ Check-in [3c933bf9]
Login

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

Overview
Comment:Take steps to avoid misestimating range query costs based on STAT4 data due to the roundoff error of converting from integers to LogEst and back to integers.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:3c933bf95f291f7957580d823dce92c981375a5c
User & Date: drh 2014-10-22 15:27:05
Context
2014-10-23
17:26
Add debugging code to count the number of iterations of each loop made as part of statement execution. Leaf check-in: c6a5b67a user: dan tags: debug-loopcounters
2014-10-22
19:57
Change the 0x800 bit of SQLITE_TESTCTRL_OPTIMIZATIONS so that it disables the loading of STAT3 and STAT4 content, not just the using of that content. Change the internal name of that bit to SQLITE_Stat34. check-in: ca3b00c4 user: drh tags: trunk
18:42
Merge latest trunk with this branch. check-in: 854a54c6 user: dan tags: defrag-opt
16:25
The _beginthreadex() / _endthreadex() functions should only be used when compiling with MSVC. Closed-Leaf check-in: 1a5a5da3 user: mistachkin tags: msvcThreads
15:27
Take steps to avoid misestimating range query costs based on STAT4 data due to the roundoff error of converting from integers to LogEst and back to integers. check-in: 3c933bf9 user: drh tags: trunk
2014-10-21
21:56
Call fsync() right after ftruncate() when in journal_mode=TRUNCATE and when synchronous=FULL in order to ensure that transactions are durable across a power loss that happens moments after the commit. Proposed fix for https://bugzilla.mozilla.org/show_bug.cgi?id=1072773. check-in: 3e922208 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/analyze.c.

  1595   1595           nRow = pFinal->anLt[iCol];
  1596   1596           nDist100 = (i64)100 * pFinal->anDLt[iCol];
  1597   1597           nSample--;
  1598   1598         }else{
  1599   1599           nRow = pIdx->aiRowEst[0];
  1600   1600           nDist100 = ((i64)100 * pIdx->aiRowEst[0]) / pIdx->aiRowEst[iCol+1];
  1601   1601         }
         1602  +      pIdx->nRowEst0 = nRow;
  1602   1603   
  1603   1604         /* Set nSum to the number of distinct (iCol+1) field prefixes that
  1604   1605         ** occur in the stat4 table for this index. Set sumEq to the sum of 
  1605   1606         ** the nEq values for column iCol for the same set (adding the value 
  1606   1607         ** only once where there exist duplicate prefixes).  */
  1607   1608         for(i=0; i<nSample; i++){
  1608   1609           if( i==(pIdx->nSample-1)

Changes to src/sqliteInt.h.

  1797   1797     unsigned isResized:1;    /* True if resizeIndexObject() has been called */
  1798   1798     unsigned isCovering:1;   /* True if this is a covering index */
  1799   1799   #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
  1800   1800     int nSample;             /* Number of elements in aSample[] */
  1801   1801     int nSampleCol;          /* Size of IndexSample.anEq[] and so on */
  1802   1802     tRowcnt *aAvgEq;         /* Average nEq values for keys not in aSample */
  1803   1803     IndexSample *aSample;    /* Samples of the left-most key */
  1804         -  tRowcnt *aiRowEst;       /* Non-logarithmic stat1 data for this table */
         1804  +  tRowcnt *aiRowEst;       /* Non-logarithmic stat1 data for this index */
         1805  +  tRowcnt nRowEst0;        /* Non-logarithmic number of rows in the index */
  1805   1806   #endif
  1806   1807   };
  1807   1808   
  1808   1809   /*
  1809   1810   ** Allowed values for Index.idxType
  1810   1811   */
  1811   1812   #define SQLITE_IDXTYPE_APPDEF      0   /* Created using CREATE INDEX */

Changes to src/where.c.

  2194   2194           aff = SQLITE_AFF_INTEGER;
  2195   2195         }else{
  2196   2196           aff = p->pTable->aCol[p->aiColumn[nEq]].affinity;
  2197   2197         }
  2198   2198         /* Determine iLower and iUpper using ($P) only. */
  2199   2199         if( nEq==0 ){
  2200   2200           iLower = 0;
  2201         -        iUpper = sqlite3LogEstToInt(p->aiRowLogEst[0]);
         2201  +        iUpper = p->nRowEst0;
  2202   2202         }else{
  2203   2203           /* Note: this call could be optimized away - since the same values must 
  2204   2204           ** have been requested when testing key $P in whereEqualScanEst().  */
  2205   2205           whereKeyStats(pParse, p, pRec, 0, a);
  2206   2206           iLower = a[0];
  2207   2207           iUpper = a[0] + a[1];
  2208   2208         }