Reusing prepared statements is slower.

This commit is contained in:
JoelKatz
2013-04-01 20:24:01 -07:00
parent 2e21391c93
commit 78d1a93e69
2 changed files with 6 additions and 19 deletions

View File

@@ -95,7 +95,7 @@ void HashedObjectStore::bulkWrite()
{
Database* db = theApp->getHashNodeDB()->getDB();
ScopedLock sl(theApp->getHashNodeDB()->getDBLock());
static SqliteStatement pSt(db->getSqliteDB(),
SqliteStatement pSt(db->getSqliteDB(),
"INSERT OR IGNORE INTO CommittedObjects "
"(Hash,ObjType,LedgerIndex,Object) VALUES (?, ?, ?, ?);");
@@ -185,7 +185,7 @@ HashedObject::pointer HashedObjectStore::retrieve(const uint256& hash)
{
ScopedLock sl(theApp->getHashNodeDB()->getDBLock());
LoadEvent::autoptr event(theApp->getJobQueue().getLoadEventAP(jtDISK, "HOS::retrieve"));
static SqliteStatement pSt(theApp->getHashNodeDB()->getDB()->getSqliteDB(),
SqliteStatement pSt(theApp->getHashNodeDB()->getDB()->getSqliteDB(),
"SELECT ObjType,LedgerIndex,Object FROM CommittedObjects WHERE Hash = ?;");
pSt.bind(1, hash.GetHex());
@@ -193,7 +193,6 @@ HashedObject::pointer HashedObjectStore::retrieve(const uint256& hash)
int ret = pSt.step();
if (pSt.isDone(ret))
{
pSt.reset();
mNegativeCache.add(hash);
cLog(lsTRACE) << "HOS: " << hash <<" fetch: not in db";
return obj;
@@ -202,7 +201,6 @@ HashedObject::pointer HashedObjectStore::retrieve(const uint256& hash)
type = pSt.peekString(0);
index = pSt.getUInt32(1);
pSt.getBlob(2).swap(data);
pSt.reset();
}
#else