diff options
author | drh <drh@noemail.net> | 2016-11-10 17:01:36 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2016-11-10 17:01:36 +0000 |
commit | c6c9e158c5c492d109cf95cefcfa9e4ee66a61ca (patch) | |
tree | 4970139f8572f58300f17851ae47e521370adf26 /src/insert.c | |
parent | bf2f5739c956bdd508d427c269e0b46c05025544 (diff) | |
download | sqlite-c6c9e158c5c492d109cf95cefcfa9e4ee66a61ca.tar.gz sqlite-c6c9e158c5c492d109cf95cefcfa9e4ee66a61ca.zip |
When doing a REPLACE on a WITHOUT ROWID table with no secondary indexes,
bypass the OP_NoConflict/OP_Delete sequence and directly overwrite any
preexisting row, for a performance increase.
FossilOrigin-Name: f7041cbb63b912f9ecad538804b6f2383efbec4e
Diffstat (limited to 'src/insert.c')
-rw-r--r-- | src/insert.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/insert.c b/src/insert.c index 85f34f068..a5852fd32 100644 --- a/src/insert.c +++ b/src/insert.c @@ -1560,6 +1560,12 @@ void sqlite3GenerateConstraintChecks( }else if( onError==OE_Default ){ onError = OE_Abort; } + + if( ix==0 && pPk==pIdx && onError==OE_Replace && pPk->pNext==0 ){ + sqlite3VdbeResolveLabel(v, addrUniqueOk); + continue; + } + /* Check to see if the new index entry will be unique */ sqlite3VdbeAddOp4Int(v, OP_NoConflict, iThisCur, addrUniqueOk, @@ -1700,7 +1706,8 @@ void sqlite3CompleteInsertion( VdbeCoverage(v); } sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iIdxCur+i, aRegIdx[i], - aRegIdx[i]+1, pIdx->nColumn); + aRegIdx[i]+1, + pIdx->uniqNotNull ? pIdx->nKeyCol: pIdx->nColumn); pik_flags = 0; if( useSeekResult ) pik_flags = OPFLAG_USESEEKRESULT; if( IsPrimaryKeyIndex(pIdx) && !HasRowid(pTab) ){ |