use a better index on support table

This commit is contained in:
Brannon King 2020-06-16 23:07:11 -06:00
parent 0b085179b6
commit 817e643420
2 changed files with 5 additions and 5 deletions

View file

@ -3,9 +3,9 @@ AC_PREREQ([2.60])
define(_CLIENT_VERSION_MAJOR, 0) define(_CLIENT_VERSION_MAJOR, 0)
define(_CLIENT_VERSION_MINOR, 17) define(_CLIENT_VERSION_MINOR, 17)
define(_CLIENT_VERSION_REVISION, 4) define(_CLIENT_VERSION_REVISION, 4)
define(_CLIENT_VERSION_BUILD, 5) define(_CLIENT_VERSION_BUILD, 6)
define(_CLIENT_VERSION_IS_RELEASE, true) define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_YEAR, 2019) define(_COPYRIGHT_YEAR, 2020)
define(_COPYRIGHT_HOLDERS,[The %s developers]) define(_COPYRIGHT_HOLDERS,[The %s developers])
define(_COPYRIGHT_HOLDERS_SUBSTITUTION,[[LBRYcrd Core]]) define(_COPYRIGHT_HOLDERS_SUBSTITUTION,[[LBRYcrd Core]])
AC_INIT([LBRYcrd Core],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[https://github.com/lbryio/lbrycrd/issues],[lbrycrd],[https://lbry.com/]) AC_INIT([LBRYcrd Core],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[https://github.com/lbryio/lbrycrd/issues],[lbrycrd],[https://lbry.com/])

View file

@ -126,7 +126,7 @@ void CClaimTrie::doNodeTableMigration()
for (auto&& row : db << "SELECT claimsHash FROM node WHERE name = x''") for (auto&& row : db << "SELECT claimsHash FROM node WHERE name = x''")
break; break;
} catch (const sqlite::sqlite_exception&) { } catch (const sqlite::sqlite_exception&) {
logPrint << "Running one-time upgrade of node table to cache the hash of claims..." << Clog::endl;
isNodeMigrationStart = true; isNodeMigrationStart = true;
// new node schema // new node schema
@ -391,7 +391,7 @@ int64_t CClaimTrieCacheBase::getTotalValueOfClaimsInTrie(bool fControllingOnly)
int64_t ret = 0; int64_t ret = 0;
const std::string query = fControllingOnly ? const std::string query = fControllingOnly ?
"SELECT SUM(amount) FROM (SELECT c.amount as amount, " "SELECT SUM(amount) FROM (SELECT c.amount as amount, "
"(SELECT(SELECT IFNULL(SUM(s.amount),0)+c.amount FROM support s " "(SELECT(SELECT IFNULL(SUM(s.amount),0)+c.amount FROM support s INDEXED BY support_supportedClaimID "
"WHERE s.supportedClaimID = c.claimID AND c.nodeName = s.nodeName " "WHERE s.supportedClaimID = c.claimID AND c.nodeName = s.nodeName "
"AND s.activationHeight < ?1 AND s.expirationHeight >= ?1) as effective " "AND s.activationHeight < ?1 AND s.expirationHeight >= ?1) as effective "
"ORDER BY effective DESC LIMIT 1) as winner FROM claim c " "ORDER BY effective DESC LIMIT 1) as winner FROM claim c "
@ -581,7 +581,7 @@ const std::string childHashQuery_s = "SELECT name, hash FROM node WHERE parent =
const std::string claimHashQuery_s = const std::string claimHashQuery_s =
"SELECT c.txID, c.txN, c.claimID, c.updateHeight, c.activationHeight, c.amount, " "SELECT c.txID, c.txN, c.claimID, c.updateHeight, c.activationHeight, c.amount, "
"(SELECT IFNULL(SUM(s.amount),0)+c.amount FROM support s " "(SELECT IFNULL(SUM(s.amount),0)+c.amount FROM support s INDEXED BY support_supportedClaimID "
"WHERE s.supportedClaimID = c.claimID AND s.nodeName = c.nodeName " "WHERE s.supportedClaimID = c.claimID AND s.nodeName = c.nodeName "
"AND s.activationHeight < ?1 AND s.expirationHeight >= ?1) as effectiveAmount " "AND s.activationHeight < ?1 AND s.expirationHeight >= ?1) as effectiveAmount "
"FROM claim c WHERE c.nodeName = ?2 AND c.activationHeight < ?1 AND c.expirationHeight >= ?1 " "FROM claim c WHERE c.nodeName = ?2 AND c.activationHeight < ?1 AND c.expirationHeight >= ?1 "