From 40f8583f5f50924d333667b0b22bc0cceb6ce087 Mon Sep 17 00:00:00 2001 From: Lucas Rubian Schatz Date: Mon, 9 Oct 2023 11:43:02 -0300 Subject: [PATCH 1/3] Fix boolean in IBPPtype2string method --- src/gui/ExecuteSqlFrame.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/ExecuteSqlFrame.cpp b/src/gui/ExecuteSqlFrame.cpp index 5005416e..6e9710f7 100644 --- a/src/gui/ExecuteSqlFrame.cpp +++ b/src/gui/ExecuteSqlFrame.cpp @@ -2244,6 +2244,7 @@ wxString IBPPtype2string(Database *db, IBPP::SDT t, int subtype, int size, case IBPP::sdLargeint: return "BIGINT"; case IBPP::sdFloat: return "FLOAT"; case IBPP::sdDouble: return "DOUBLE PRECISION"; + case IBPP::sdBoolean: return "BOOLEAN"; case IBPP::sdTimeTz: return "TIME WITH TIMEZONE"; case IBPP::sdTimestampTz: return "TIMESTAMP WITH TIMEZONE"; case IBPP::sdInt128: return "INT128"; From 48868e29d3a9b87a4845a719a381d96e59502354 Mon Sep 17 00:00:00 2001 From: Lucas Rubian Schatz Date: Mon, 9 Oct 2023 11:51:54 -0300 Subject: [PATCH 2/3] Add per table detailed index/seq read --- src/ibpp/_rb.cpp | 4 ++++ src/ibpp/database.cpp | 4 ++++ src/ibpp/ibpp.h | 4 +++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/ibpp/_rb.cpp b/src/ibpp/_rb.cpp index baed8ffb..55eb0e92 100644 --- a/src/ibpp/_rb.cpp +++ b/src/ibpp/_rb.cpp @@ -150,6 +150,10 @@ void RB::GetDetailedCounts(IBPP::DatabaseCounts& counts, char token) (*it).second.updates += value; if (token == isc_info_delete_count) (*it).second.deletes += value; + if (token == isc_info_read_idx_count) + (*it).second.readIndex += value; + if (token == isc_info_read_seq_count) + (*it).second.readSequence += value; p += 6; len -= 6; } diff --git a/src/ibpp/database.cpp b/src/ibpp/database.cpp index 354e0fc2..75929cf6 100644 --- a/src/ibpp/database.cpp +++ b/src/ibpp/database.cpp @@ -352,6 +352,8 @@ void DatabaseImpl::DetailedCounts(IBPP::DatabaseCounts& counts) char items[] = {isc_info_insert_count, isc_info_update_count, isc_info_delete_count, + isc_info_read_idx_count, + isc_info_read_seq_count, isc_info_end}; IBS status; RB result(1024); @@ -365,6 +367,8 @@ void DatabaseImpl::DetailedCounts(IBPP::DatabaseCounts& counts) result.GetDetailedCounts(counts, isc_info_insert_count); result.GetDetailedCounts(counts, isc_info_update_count); result.GetDetailedCounts(counts, isc_info_delete_count); + result.GetDetailedCounts(counts, isc_info_read_idx_count); + result.GetDetailedCounts(counts, isc_info_read_seq_count); } void DatabaseImpl::Users(std::vector& users) diff --git a/src/ibpp/ibpp.h b/src/ibpp/ibpp.h index 0f732e0b..fdd46838 100644 --- a/src/ibpp/ibpp.h +++ b/src/ibpp/ibpp.h @@ -670,10 +670,12 @@ namespace IBPP class CountInfo { public: - CountInfo(): inserts(0), updates(0), deletes(0) {} + CountInfo(): inserts(0), updates(0), deletes(0), readIndex(0), readSequence(0) {} int inserts; int updates; int deletes; + int readIndex; + int readSequence; }; typedef std::map DatabaseCounts; // int = relation ID From 41249aa08a4bae4be683a832e48a6cc96e0ab774 Mon Sep 17 00:00:00 2001 From: Lucas Rubian Schatz Date: Mon, 9 Oct 2023 11:53:22 -0300 Subject: [PATCH 3/3] Allow user to enable/disable stats at SQL editor screen --- src/gui/CommandIds.h | 1 + src/gui/ExecuteSqlFrame.cpp | 21 ++++++++++++++++++++- src/gui/ExecuteSqlFrame.h | 3 +++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/gui/CommandIds.h b/src/gui/CommandIds.h index ee8cd689..48320d7a 100644 --- a/src/gui/CommandIds.h +++ b/src/gui/CommandIds.h @@ -42,6 +42,7 @@ enum { // SQL Query Query_Execute, Query_Show_plan, + Query_Show_Statistics, Query_Execute_selection, Query_Execute_from_cursor, Query_Commit, diff --git a/src/gui/ExecuteSqlFrame.cpp b/src/gui/ExecuteSqlFrame.cpp index 6e9710f7..05e3a3a9 100644 --- a/src/gui/ExecuteSqlFrame.cpp +++ b/src/gui/ExecuteSqlFrame.cpp @@ -530,6 +530,7 @@ ExecuteSqlFrame::ExecuteSqlFrame(wxWindow* WXUNUSED(parent), int id, transactionIsolationLevelM = static_cast(config().get("transactionIsolationLevel", 0)); transactionLockResolutionM = config().get("transactionLockResolution", true) ? IBPP::lrWait : IBPP::lrNoWait; transactionAccessModeM = config().get("transactionAccessMode", false) ? IBPP::amRead : IBPP::amWrite; + showStatisticsM = config().get("SQLEditorShowStats", true); timerBlobEditorM.SetOwner(this, TIMER_ID_UPDATE_BLOB); @@ -730,6 +731,8 @@ void ExecuteSqlFrame::buildMainMenu(CommandManager& cm) cm.getMainMenuItemText(_("&Execute"), Cmds::Query_Execute)); statementMenu->Append(Cmds::Query_Show_plan, cm.getMainMenuItemText(_("Show execution &plan"), Cmds::Query_Show_plan)); + statementMenu->AppendCheckItem(Cmds::Query_Show_Statistics, + cm.getMainMenuItemText(_("Display detailed query statistics"), Cmds::Query_Show_Statistics)); statementMenu->Append(Cmds::Query_Execute_selection, cm.getMainMenuItemText(_("Execute &selection"), Cmds::Query_Execute_selection)); statementMenu->Append(Cmds::Query_Execute_from_cursor, @@ -950,6 +953,8 @@ BEGIN_EVENT_TABLE(ExecuteSqlFrame, wxFrame) EVT_MENU(Cmds::Query_Execute, ExecuteSqlFrame::OnMenuExecute) EVT_MENU(Cmds::Query_Show_plan, ExecuteSqlFrame::OnMenuShowPlan) + EVT_MENU(Cmds::Query_Show_Statistics, ExecuteSqlFrame::OnMenuShowStatistics) + EVT_UPDATE_UI(Cmds::Query_Show_Statistics, ExecuteSqlFrame::OnMenuUpdateShowStatistics) EVT_MENU(Cmds::Query_Execute_selection, ExecuteSqlFrame::OnMenuExecuteSelection) EVT_MENU(Cmds::Query_Execute_from_cursor, ExecuteSqlFrame::OnMenuExecuteFromCursor) EVT_UPDATE_UI(Cmds::Query_Execute, ExecuteSqlFrame::OnMenuUpdateWhenExecutePossible) @@ -1619,6 +1624,16 @@ void ExecuteSqlFrame::OnMenuShowPlan(wxCommandEvent& WXUNUSED(event)) prepareAndExecute(true); } +void ExecuteSqlFrame::OnMenuShowStatistics(wxCommandEvent& event) +{ + showStatisticsM = event.IsChecked(); +} + +void ExecuteSqlFrame::OnMenuUpdateShowStatistics(wxUpdateUIEvent& event) +{ + event.Check(showStatisticsM); +} + void ExecuteSqlFrame::OnMenuExecuteFromCursor(wxCommandEvent& WXUNUSED(event)) { clearLogBeforeExecution(); @@ -2273,6 +2288,10 @@ void ExecuteSqlFrame::compareCounts(IBPP::DatabaseCounts& one, str_log += wxString::Format(_("%d updates. "), r1.updates - r2.updates); if (r1.deletes > r2.deletes) str_log += wxString::Format(_("%d deletes. "), r1.deletes - r2.deletes); + if (r1.readIndex > r2.readIndex) + str_log += wxString::Format(_("%d reads index. "), r1.readIndex - r2.readIndex); + if (r1.readSequence > r2.readSequence) + str_log += wxString::Format(_("%d reads sequence. "), r1.readSequence - r2.readSequence); if (!str_log.IsEmpty()) { wxString relName; @@ -2387,7 +2406,7 @@ bool ExecuteSqlFrame::execute(wxString sql, const wxString& terminator, del1 = 0, ridx1 = 0, rseq1 = 0, mem1 = 0; int fetch2, mark2, read2, write2, ins2, upd2, del2, ridx2, rseq2, mem2; IBPP::DatabaseCounts counts1, counts2; - bool doShowStats = config().get("SQLEditorShowStats", true); + bool doShowStats = showStatisticsM; if (!prepareOnly && doShowStats) { databaseM->getIBPPDatabase()-> diff --git a/src/gui/ExecuteSqlFrame.h b/src/gui/ExecuteSqlFrame.h index 79354749..fdcc01a6 100644 --- a/src/gui/ExecuteSqlFrame.h +++ b/src/gui/ExecuteSqlFrame.h @@ -121,6 +121,7 @@ class ExecuteSqlFrame: public BaseFrame, public Observer IBPP::TIL transactionIsolationLevelM; IBPP::TLR transactionLockResolutionM; IBPP::TAM transactionAccessModeM; + bool showStatisticsM; void inTransaction(bool started); // changes controls (enable/disable) bool commitTransaction(); bool rollbackTransaction(); @@ -210,6 +211,8 @@ class ExecuteSqlFrame: public BaseFrame, public Observer void OnMenuExecute(wxCommandEvent& event); void OnMenuShowPlan(wxCommandEvent& event); + void OnMenuShowStatistics(wxCommandEvent& event); + void OnMenuUpdateShowStatistics(wxUpdateUIEvent& event); void OnMenuExecuteSelection(wxCommandEvent& event); void OnMenuExecuteFromCursor(wxCommandEvent& event); void OnMenuCommit(wxCommandEvent& event);