mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-19 10:35:50 +00:00
Skip inefficent SQL query (RIPD-870):
For large data sets the JOIN may not make forward progress in time. This prevents the deletion of those entries in the database during online delete. The number of such entries is very small compared to the total size of the data anyway. A future version will address this more thoroughly.
This commit is contained in:
committed by
Vinnie Falco
parent
5a3168c9ff
commit
5b0109055d
@@ -4496,6 +4496,8 @@
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\soci\src\core\values.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\soci\src\core\version.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\sqlite\sqlite.h">
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\sqlite\sqlite.unity.c">
|
||||
|
||||
@@ -5274,6 +5274,9 @@
|
||||
<ClInclude Include="..\..\src\soci\src\core\values.h">
|
||||
<Filter>soci\src\core</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\soci\src\core\version.h">
|
||||
<Filter>soci\src\core</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\sqlite\sqlite.h">
|
||||
<Filter>sqlite</Filter>
|
||||
</ClInclude>
|
||||
|
||||
@@ -354,22 +354,6 @@ public:
|
||||
soci::into (validationsLH);
|
||||
expect (ledgersLS.size () == numRows &&
|
||||
validationsLH.size () == numRows);
|
||||
s << "DELETE FROM Validations WHERE LedgerHash IN "
|
||||
"(SELECT Ledgers.LedgerHash FROM Validations JOIN Ledgers ON "
|
||||
"Validations.LedgerHash=Ledgers.LedgerHash WHERE "
|
||||
"Ledgers.LedgerSeq < :num);",
|
||||
soci::use (numRows / 2);
|
||||
validationsLH.resize (numRows * 2);
|
||||
s << "SELECT LedgerHash FROM Validations;",
|
||||
soci::into (validationsLH);
|
||||
expect (validationsLH.size () == numRows / 2);
|
||||
for (auto i = ledgerHashes.begin () + numRows / 2;
|
||||
i != ledgerHashes.end ();
|
||||
++i)
|
||||
{
|
||||
expect (find (validationsLH.begin (), validationsLH.end (), *i)
|
||||
!= validationsLH.end ());
|
||||
}
|
||||
}
|
||||
using namespace boost::filesystem;
|
||||
// Remove the database
|
||||
|
||||
@@ -570,12 +570,18 @@ SHAMapStoreImp::clearPrior (LedgerIndex lastRotated)
|
||||
|
||||
// TODO This won't remove validations for ledgers that do not get
|
||||
// validated. That will likely require inserting LedgerSeq into
|
||||
// the validations table
|
||||
// the validations table.
|
||||
//
|
||||
// This query has poor performance with large data sets.
|
||||
// The schema needs to be redesigned to avoid the JOIN, or an
|
||||
// RDBMS that supports concurrency should be used.
|
||||
/*
|
||||
clearSql (*ledgerDb_, lastRotated,
|
||||
"SELECT MIN(LedgerSeq) FROM Ledgers;",
|
||||
"DELETE FROM Validations WHERE LedgerHash IN "
|
||||
"(SELECT Ledgers.LedgerHash FROM Validations JOIN Ledgers ON "
|
||||
"Validations.LedgerHash=Ledgers.LedgerHash WHERE Ledgers.LedgerSeq < %u);");
|
||||
*/
|
||||
|
||||
if (health())
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user