/ Changes On Branch apple-increased-sorting-cost
Login

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

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

This is equivalent to a diff from a07c581e88 to 38298ef923

2017-02-17
21:23
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. (Leaf check-in: 38298ef923 user: drh tags: apple-increased-sorting-cost)
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)
2016-11-26
20:12
Update test case for opening SHM files read/write on a read-only connection so that they are only attempted on Darwin with SQLITE_ENABLE_PRESIST_WAL. (check-in: d6a7bf80cf user: drh tags: apple-osx)
2016-11-17
14:02
When opening the *-shm file for a readonly database, try to open it in read-write mode before falling back to readonly. This is in case some other read/write connection within the same process uses the same file descriptor. (check-in: a07c581e88 user: dan tags: apple-osx)
2016-11-04
19:09
Merge recent trunk changes, including all the fixes that appeared in version 3.15.1. (check-in: 0e5ffd9123 user: drh tags: apple-osx)

Changes to src/where.c.

3786
3787
3788
3789
3790
3791
3792










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







+
+
+
+
+
+
+
+
+
+







  **
  ** 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->pDistinctSet
   && pWInfo->pDistinctSet->nExpr>6
  ){
    rSortCost += sqlite3LogEst(pWInfo->pDistinctSet->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);