-
Notifications
You must be signed in to change notification settings - Fork 972
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1576 from MonsieurNicolas/maintenancePerfFix
improve query used to delete old entries during maintenance Reviewed-by: jonjove
- Loading branch information
Showing
7 changed files
with
69 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright 2018 Stellar Development Foundation and contributors. Licensed | ||
// under the Apache License, Version 2.0. See the COPYING file at the root | ||
// of this distribution or at http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
#include "DatabaseUtils.h" | ||
|
||
namespace stellar | ||
{ | ||
namespace DatabaseUtils | ||
{ | ||
void | ||
deleteOldEntriesHelper(soci::session& sess, uint32_t ledgerSeq, uint32_t count, | ||
std::string const& tableName, | ||
std::string const& ledgerSeqColumn) | ||
{ | ||
uint32_t curMin = 0; | ||
soci::indicator gotMin; | ||
soci::statement st = (sess.prepare << "SELECT MIN(" << ledgerSeqColumn | ||
<< ") FROM " << tableName, | ||
soci::into(curMin, gotMin)); | ||
|
||
st.execute(true); | ||
if (st.got_data() && gotMin == soci::i_ok) | ||
{ | ||
uint32 m = std::min(curMin + count, ledgerSeq); | ||
sess << "DELETE FROM " << tableName << " WHERE " << ledgerSeqColumn | ||
<< " <= " << m; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#pragma once | ||
|
||
// Copyright 2018 Stellar Development Foundation and contributors. Licensed | ||
// under the Apache License, Version 2.0. See the COPYING file at the root | ||
// of this distribution or at http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
#include "Database.h" | ||
|
||
namespace stellar | ||
{ | ||
namespace DatabaseUtils | ||
{ | ||
void deleteOldEntriesHelper(soci::session& sess, uint32_t ledgerSeq, | ||
uint32_t count, std::string const& tableName, | ||
std::string const& ledgerSeqColumn); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters