/ Check-in [6705ab1a]
Login

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

Overview
Comment:Shift more OP_Found opcodes over to using the unpacked format, for improved performance.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 6705ab1ad12cbdbbcf1f3e5439a4e6cbdcc421b3
User & Date: drh 2009-11-12 20:39:03
Context
2009-11-13
10:04
Changes to test_intarray.c so that it build with SQLITE_OMIT_VIRTUALTABLE. Added testcase() macros to expr.c. check-in: f0599d28 user: drh tags: trunk
2009-11-12
20:39
Shift more OP_Found opcodes over to using the unpacked format, for improved performance. check-in: 6705ab1a user: drh tags: trunk
19:59
Enhance the OP_Found and OP_NotFound opcodes so that they can accept an array of registers as an unpacked record in addition to a record built using OP_MakeRecord. Use this to avoid OP_MakeRecord calls during IN expression processing. check-in: b9eab885 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/pragma.c.

  1124   1124           sqlite3VdbeJumpHere(v, addr);
  1125   1125           sqlite3OpenTableAndIndices(pParse, pTab, 1, OP_OpenRead);
  1126   1126           sqlite3VdbeAddOp2(v, OP_Integer, 0, 2);  /* reg(2) will count entries */
  1127   1127           loopTop = sqlite3VdbeAddOp2(v, OP_Rewind, 1, 0);
  1128   1128           sqlite3VdbeAddOp2(v, OP_AddImm, 2, 1);   /* increment entry count */
  1129   1129           for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
  1130   1130             int jmp2;
         1131  +          int r1;
  1131   1132             static const VdbeOpList idxErr[] = {
  1132   1133               { OP_AddImm,      1, -1,  0},
  1133   1134               { OP_String8,     0,  3,  0},    /* 1 */
  1134   1135               { OP_Rowid,       1,  4,  0},
  1135   1136               { OP_String8,     0,  5,  0},    /* 3 */
  1136   1137               { OP_String8,     0,  6,  0},    /* 4 */
  1137   1138               { OP_Concat,      4,  3,  3},
  1138   1139               { OP_Concat,      5,  3,  3},
  1139   1140               { OP_Concat,      6,  3,  3},
  1140   1141               { OP_ResultRow,   3,  1,  0},
  1141   1142               { OP_IfPos,       1,  0,  0},    /* 9 */
  1142   1143               { OP_Halt,        0,  0,  0},
  1143   1144             };
  1144         -          sqlite3GenerateIndexKey(pParse, pIdx, 1, 3, 1);
  1145         -          jmp2 = sqlite3VdbeAddOp4Int(v, OP_Found, j+2, 0, 3, 0);
         1145  +          r1 = sqlite3GenerateIndexKey(pParse, pIdx, 1, 3, 0);
         1146  +          jmp2 = sqlite3VdbeAddOp4Int(v, OP_Found, j+2, 0, r1, pIdx->nColumn+1);
  1146   1147             addr = sqlite3VdbeAddOpList(v, ArraySize(idxErr), idxErr);
  1147   1148             sqlite3VdbeChangeP4(v, addr+1, "rowid ", P4_STATIC);
  1148   1149             sqlite3VdbeChangeP4(v, addr+3, " missing from index ", P4_STATIC);
  1149   1150             sqlite3VdbeChangeP4(v, addr+4, pIdx->zName, P4_STATIC);
  1150   1151             sqlite3VdbeJumpHere(v, addr+9);
  1151   1152             sqlite3VdbeJumpHere(v, jmp2);
  1152   1153           }

Changes to src/select.c.

   435    435     int iMem           /* First element */
   436    436   ){
   437    437     Vdbe *v;
   438    438     int r1;
   439    439   
   440    440     v = pParse->pVdbe;
   441    441     r1 = sqlite3GetTempReg(pParse);
          442  +  sqlite3VdbeAddOp4Int(v, OP_Found, iTab, addrRepeat, iMem, N);
   442    443     sqlite3VdbeAddOp3(v, OP_MakeRecord, iMem, N, r1);
   443         -  sqlite3VdbeAddOp4Int(v, OP_Found, iTab, addrRepeat, r1, 0);
   444    444     sqlite3VdbeAddOp2(v, OP_IdxInsert, iTab, r1);
   445    445     sqlite3ReleaseTempReg(pParse, r1);
   446    446   }
   447    447   
   448    448   /*
   449    449   ** Generate an error message when a SELECT is used within a subexpression
   450    450   ** (example:  "a IN (SELECT * FROM table)") but it has more than 1 result