Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Have the planner detect cases where a MATCH constraint is applied to a virtual table, and ignore any plans that do not allow the virtual table implementation to implement the MATCH filtering. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | avoid-unusable-match |
Files: | files | file ages | folders |
SHA1: |
19f3208b26597625728d1ef716d4e444 |
User & Date: | dan 2014-01-04 14:16:06.902 |
Context
2014-01-04
| ||
14:42 | Instead of having the planner ignore plans with unusable MATCH constraints, have FTS assign extremely high costs to such plans in order to discourage the planner from using them. (Closed-Leaf check-in: 24f84b3813 user: dan tags: avoid-unusable-match) | |
14:16 | Have the planner detect cases where a MATCH constraint is applied to a virtual table, and ignore any plans that do not allow the virtual table implementation to implement the MATCH filtering. (check-in: 19f3208b26 user: dan tags: avoid-unusable-match) | |
2014-01-03
| ||
16:03 | Avoid some unnecessary OP_SCopy operations when inserting into a table with multiple indices. (check-in: 429018b19c user: drh tags: trunk) | |
Changes
Changes to src/where.c.
︙ | ︙ | |||
4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 | struct sqlite3_index_constraint_usage *pUsage; WhereTerm *pTerm; int i, j; int iTerm, mxTerm; int nConstraint; int seenIn = 0; /* True if an IN operator is seen */ int seenVar = 0; /* True if a non-constant constraint is seen */ int iPhase; /* 0: const w/o IN, 1: const, 2: no IN, 2: IN */ WhereLoop *pNew; int rc = SQLITE_OK; pWInfo = pBuilder->pWInfo; pParse = pWInfo->pParse; db = pParse->db; | > | 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 | struct sqlite3_index_constraint_usage *pUsage; WhereTerm *pTerm; int i, j; int iTerm, mxTerm; int nConstraint; int seenIn = 0; /* True if an IN operator is seen */ int seenVar = 0; /* True if a non-constant constraint is seen */ int seenVarMatch = 0; /* If a non-constant MATCH constraint is seen */ int iPhase; /* 0: const w/o IN, 1: const, 2: no IN, 2: IN */ WhereLoop *pNew; int rc = SQLITE_OK; pWInfo = pBuilder->pWInfo; pParse = pWInfo->pParse; db = pParse->db; |
︙ | ︙ | |||
4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 | case 0: /* Constants without IN operator */ pIdxCons->usable = 0; if( (pTerm->eOperator & WO_IN)!=0 ){ seenIn = 1; } if( pTerm->prereqRight!=0 ){ seenVar = 1; }else if( (pTerm->eOperator & WO_IN)==0 ){ pIdxCons->usable = 1; } break; case 1: /* Constants with IN operators */ assert( seenIn ); pIdxCons->usable = (pTerm->prereqRight==0); break; case 2: /* Variables without IN */ assert( seenVar ); pIdxCons->usable = (pTerm->eOperator & WO_IN)==0; break; default: /* Variables with IN */ assert( seenVar && seenIn ); pIdxCons->usable = 1; break; } } memset(pUsage, 0, sizeof(pUsage[0])*pIdxInfo->nConstraint); if( pIdxInfo->needToFreeIdxStr ) sqlite3_free(pIdxInfo->idxStr); pIdxInfo->idxStr = 0; pIdxInfo->idxNum = 0; pIdxInfo->needToFreeIdxStr = 0; pIdxInfo->orderByConsumed = 0; pIdxInfo->estimatedCost = SQLITE_BIG_DBL / (double)2; | > > > > | 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 | case 0: /* Constants without IN operator */ pIdxCons->usable = 0; if( (pTerm->eOperator & WO_IN)!=0 ){ seenIn = 1; } if( pTerm->prereqRight!=0 ){ seenVar = 1; if( pTerm->eOperator & WO_MATCH ) seenVarMatch = 1; }else if( (pTerm->eOperator & WO_IN)==0 ){ pIdxCons->usable = 1; } break; case 1: /* Constants with IN operators */ assert( seenIn ); pIdxCons->usable = (pTerm->prereqRight==0); break; case 2: /* Variables without IN */ assert( seenVar ); pIdxCons->usable = (pTerm->eOperator & WO_IN)==0; break; default: /* Variables with IN */ assert( seenVar && seenIn ); pIdxCons->usable = 1; break; } } /* The following line ensures that, if there exists a MATCH constraint, ** no plans for which the MATCH constraint is not usable are considered. */ if( seenVarMatch && iPhase<=1 ) continue; memset(pUsage, 0, sizeof(pUsage[0])*pIdxInfo->nConstraint); if( pIdxInfo->needToFreeIdxStr ) sqlite3_free(pIdxInfo->idxStr); pIdxInfo->idxStr = 0; pIdxInfo->idxNum = 0; pIdxInfo->needToFreeIdxStr = 0; pIdxInfo->orderByConsumed = 0; pIdxInfo->estimatedCost = SQLITE_BIG_DBL / (double)2; |
︙ | ︙ |
Added test/fts3join.test.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | # 2014 January 4 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #************************************************************************* # This file implements regression tests for SQLite library. The # focus of this script is testing the FTS3 module. # set testdir [file dirname $argv0] source $testdir/tester.tcl set ::testprefix fts3join # If SQLITE_ENABLE_FTS3 is defined, omit this file. ifcapable !fts3 { finish_test return } do_execsql_test 1.0 { CREATE VIRTUAL TABLE ft1 USING fts4(x); INSERT INTO ft1 VALUES('aaa aaa'); INSERT INTO ft1 VALUES('aaa bbb'); INSERT INTO ft1 VALUES('bbb aaa'); INSERT INTO ft1 VALUES('bbb bbb'); CREATE TABLE t1(id, y); INSERT INTO t1 VALUES(1, 'aaa'); INSERT INTO t1 VALUES(2, 'bbb'); } do_execsql_test 1.1 { SELECT docid FROM ft1, t1 WHERE ft1 MATCH y AND id=1; } {1 2 3} do_execsql_test 1.2 { SELECT docid FROM ft1, t1 WHERE ft1 MATCH y AND id=1 ORDER BY docid; } {1 2 3} do_execsql_test 2.0 { CREATE VIRTUAL TABLE ft2 USING fts4(x); CREATE VIRTUAL TABLE ft3 USING fts4(y); INSERT INTO ft2 VALUES('abc'); INSERT INTO ft2 VALUES('def'); INSERT INTO ft3 VALUES('ghi'); INSERT INTO ft3 VALUES('abc'); } do_execsql_test 2.1 { SELECT * FROM ft2, ft3 WHERE x MATCH y; } {abc abc} do_execsql_test 2.2 { SELECT * FROM ft2, ft3 WHERE y MATCH x; } {abc abc} do_execsql_test 2.3 { SELECT * FROM ft3, ft2 WHERE x MATCH y; } {abc abc} do_execsql_test 2.4 { SELECT * FROM ft3, ft2 WHERE y MATCH x; } {abc abc} do_catchsql_test 2.5 { SELECT * FROM ft3, ft2 WHERE y MATCH x AND x MATCH y; } {1 {no query solution}} finish_test |