/ Changes On Branch increased-sorting-cost
Login

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

Changes In Branch increased-sorting-cost Excluding Merge-Ins

This is equivalent to a diff from 218b2bbb0d to 662e8ccf7e

2017-02-17
23:52
Fix the #endif location for an #ifndef SQLITE_UNTESTABLE macro in the command-line shell. (check-in: 8cc9d74c17 user: drh tags: trunk)
13:38
Enhance the Index and Table objects so that they remember if their stats come from the sqlite_stat1 table. Make the "PRAGMA stats" an SQLITE_DEBUG only pragma. Add the flags column to "PRAGMA stats". These are all preliminary steps toward a "PRAGMA analyze_ifneeded;" feature. (check-in: 85026c8ee1 user: drh tags: auto-analyze)
02:07
Merge fixes from trunk. (Leaf check-in: 662e8ccf7e user: drh tags: increased-sorting-cost)
02:04
Fix a test case that was made to fail by the LIKE optimization enhancement in check-in [158290c0ab] but which went unnoticed because test builds were running with ICU enabled and ICU disables the LIKE optimization. (check-in: 218b2bbb0d user: drh tags: trunk)
01:43
Enable the ".wheretrace" and ".selecttrace" extensions in the command-line shell when compiled on Windows using DEBUG=3 or higher. Fix a harmless warning in the shell that comes up when compiled this way. (check-in: 8a03be1dc4 user: drh tags: trunk)
2017-02-16
21:29
Increase the estimated cost of sorting when sorting wide results sets, to account for the extra storage space and I/O required for the external sort. (check-in: aa0703e5ce user: drh tags: increased-sorting-cost)

Changes to src/where.c.

3788
3789
3790
3791
3792
3793
3794










3795
3796
3797
3798
3799
3800
3801
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811







+
+
+
+
+
+
+
+
+
+







  **
  ** The (Y/X) term is implemented using stack variable rScale
  ** below.  */
  LogEst rScale, rSortCost;
  assert( nOrderBy>0 && 66==sqlite3LogEst(100) );
  rScale = sqlite3LogEst((nOrderBy-nSorted)*100/nOrderBy) - 66;
  rSortCost = nRow + rScale + 16;

  /* For wide sorts (many payload columns) increase the sorting cost
  ** to account for the additional I/O used by the external sorting
  ** algorithm when it flushes PMAs to disk.
  */
  if( pWInfo->pResultSet
   && pWInfo->pResultSet->nExpr>6
  ){
    rSortCost += sqlite3LogEst(pWInfo->pResultSet->nExpr) - 26;
  }

  /* Multiple by log(M) where M is the number of output rows.
  ** Use the LIMIT for M if it is smaller */
  if( (pWInfo->wctrlFlags & WHERE_USE_LIMIT)!=0 && pWInfo->iLimit<nRow ){
    nRow = pWInfo->iLimit;
  }
  rSortCost += estLog(nRow);