/ Check-in [db5a2364]
Login

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

Overview
Comment:Skip-ahead does not always work. So we still have to check for redundancy.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | skip-ahead-distinct
Files: files | file ages | folders
SHA1:db5a2364ebfbb6e54e0141ca57ccabdcc83ac41d
User & Date: drh 2016-04-15 16:17:31
Context
2016-04-15
16:27
Skip-ahead is now just an optimization. If it gets confused, it falls back to an incremental scan with redundancy elimination. check-in: 6fac0b92 user: drh tags: skip-ahead-distinct
16:17
Skip-ahead does not always work. So we still have to check for redundancy. check-in: db5a2364 user: drh tags: skip-ahead-distinct
15:54
Fixes to the skip-ahead distinct logic. More issues remain. check-in: 45a70b2b user: drh tags: skip-ahead-distinct
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/select.c.

   742    742     /* If the DISTINCT keyword was present on the SELECT statement
   743    743     ** and this row has been seen before, then do not make this row
   744    744     ** part of the result.
   745    745     */
   746    746     if( hasDistinct ){
   747    747       switch( pDistinct->eTnctType ){
   748    748         case WHERE_DISTINCT_ORDERED: {
   749         -#if 0
          749  +#if 1
   750    750           VdbeOp *pOp;            /* No longer required OpenEphemeral instr. */
   751    751           int iJump;              /* Jump destination */
   752    752           int regPrev;            /* Previous row content */
   753    753   
   754    754           /* Allocate space for the previous row */
   755    755           regPrev = pParse->nMem+1;
   756    756           pParse->nMem += nResultCol;

Changes to test/distinct2.test.

    73     73     CREATE TABLE t5(a INT, b INT);
    74     74     CREATE UNIQUE INDEX t5x ON t5(a+b);
    75     75     INSERT INTO t5(a,b) VALUES(0,0),(1,0),(1,1),(0,3);
    76     76     CREATE TEMP TABLE out AS SELECT DISTINCT a+b FROM t5;
    77     77     SELECT * FROM out ORDER BY 1;
    78     78   } {0 1 2 3}
    79     79   
           80  +do_execsql_test 600 {
           81  +  CREATE TABLE t6a(x INTEGER PRIMARY KEY);
           82  +  INSERT INTO t6a VALUES(1);
           83  +  CREATE TABLE t6b(y INTEGER PRIMARY KEY);
           84  +  INSERT INTO t6b VALUES(2),(3);
           85  +  SELECT DISTINCT x, x FROM t6a, t6b;
           86  +} {1 1}
    80     87   
    81     88   finish_test