/ Check-in [aa0703e5]
Login

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

Overview
Comment: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.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | increased-sorting-cost
Files: files | file ages | folders
SHA1:aa0703e5cef0c61bec965d4c88ee48bbc11c3649
User & Date: drh 2017-02-16 21:29:53
Context
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: 38298ef9 user: drh tags: apple-increased-sorting-cost
02:07
Merge fixes from trunk. Leaf check-in: 662e8ccf user: drh tags: 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: aa0703e5 user: drh tags: increased-sorting-cost
20:52
Change the name of WhereInfo.pDistinctSet to pResultSet, since it is now used for more than just DISTINCT processing. check-in: 9fc5cd50 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/where.c.

3788
3789
3790
3791
3792
3793
3794










3795
3796
3797
3798
3799
3800
3801
  **
  ** 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;











  /* 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);







>
>
>
>
>
>
>
>
>
>







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);