Optimize sqlite index data deletion

On sqlite, deleting doesn't require painstakingly recreating the same
exact data that was used for putting, we can just sweep out everything
with the given header num at once. Cuts roughly 1/4 out of erase time.
This commit is contained in:
Panu Matilainen 2019-10-18 12:06:11 +03:00
parent 77af8e5911
commit 5bf88af9cc
1 changed files with 7 additions and 13 deletions

View File

@ -563,26 +563,20 @@ static rpmRC sqlite_idxdbPut(dbiIndex dbi, rpmTagVal rpmtag, unsigned int hdrNum
return tag2index(dbi, rpmtag, hdrNum, h, sqlite_idxdbPutOne);
}
static rpmRC sqlite_idxdbDelOne(dbiIndex dbi, dbiCursor dbc, const char *keyp, size_t keylen, dbiIndexItem rec)
static rpmRC sqlite_idxdbDel(dbiIndex dbi, rpmTagVal rpmtag, unsigned int hdrNum, Header h)
{
int rc = dbiCursorPrep(dbc,
"DELETE FROM '%q' WHERE key=? AND hnum=? AND idx=?",
dbi->dbi_file);
dbiCursor dbc = dbiCursorInit(dbi, DBC_WRITE);
int rc = dbiCursorPrep(dbc, "DELETE FROM '%q' WHERE hnum=?", dbi->dbi_file);
if (!rc)
rc = dbiCursorBindIdx(dbc, keyp, keylen, rec);
rc = dbiCursorBindPkg(dbc, hdrNum, NULL, 0);
if (!rc)
while ((rc = sqlite3_step(dbc->stmt)) == SQLITE_ROW) {};
return dbiCursorResult(dbc);
}
static rpmRC sqlite_idxdbDel(dbiIndex dbi, rpmTagVal rpmtag, unsigned int hdrNum, Header h)
{
return tag2index(dbi, rpmtag, hdrNum, h, sqlite_idxdbDelOne);
rc = dbiCursorResult(dbc);
dbiCursorFree(dbi, dbc);
return rc;
}
static const void * sqlite_idxdbKey(dbiIndex dbi, dbiCursor dbc, unsigned int *keylen)