mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-06 18:24:26 +08:00
Autolimit optimizations:
- Do not uncheck the LIMIT checkbox if the value in EditLimitEnd is larger than the total row count. In such (very common) cases it doesn't matter if a LIMIT is applied or not, so we don't annoy the user now by not auto-unchecking it. - EditLimitEnd's value was never increased, only decreased, as of r1521. This seems more annoying than it helps prioritizing what the user wants.
This commit is contained in:
@ -396,7 +396,7 @@ type
|
|||||||
function ExecuteQuery(query: String): TDataSet;
|
function ExecuteQuery(query: String): TDataSet;
|
||||||
function CreateOrGetRemoteQueryTab(sender: THandle): THandle;
|
function CreateOrGetRemoteQueryTab(sender: THandle): THandle;
|
||||||
procedure menuDeleteSnippetClick(Sender: TObject);
|
procedure menuDeleteSnippetClick(Sender: TObject);
|
||||||
function GetCalculatedLimit( Table: String ): Int64;
|
procedure GetCalculatedLimit(Table: String; out Limit, AllRows: Int64);
|
||||||
procedure menuExploreClick(Sender: TObject);
|
procedure menuExploreClick(Sender: TObject);
|
||||||
procedure menuInsertSnippetAtCursorClick(Sender: TObject);
|
procedure menuInsertSnippetAtCursorClick(Sender: TObject);
|
||||||
procedure menuLoadSnippetClick(Sender: TObject);
|
procedure menuLoadSnippetClick(Sender: TObject);
|
||||||
@ -1175,9 +1175,7 @@ var
|
|||||||
PrimaryKeyColumns : TStringList;
|
PrimaryKeyColumns : TStringList;
|
||||||
reg_value : String;
|
reg_value : String;
|
||||||
select_base : String;
|
select_base : String;
|
||||||
limit,
|
limit, allrows : Int64;
|
||||||
tmpLimitStart,
|
|
||||||
tmpLimitEnd : Int64;
|
|
||||||
ds : TDataSet;
|
ds : TDataSet;
|
||||||
sl_query : TStringList;
|
sl_query : TStringList;
|
||||||
DisplayedColumnsList : TStringList;
|
DisplayedColumnsList : TStringList;
|
||||||
@ -1191,16 +1189,14 @@ begin
|
|||||||
// and the user did not explicitely set the limits and pressed OK in mainform
|
// and the user did not explicitely set the limits and pressed OK in mainform
|
||||||
if (Sender <> Mainform.ButtonOK) and (not dataselected) then begin
|
if (Sender <> Mainform.ButtonOK) and (not dataselected) then begin
|
||||||
// limit number of rows fetched if more than ~ 5 MB of data
|
// limit number of rows fetched if more than ~ 5 MB of data
|
||||||
limit := GetCalculatedLimit( SelectedTable );
|
GetCalculatedLimit( SelectedTable, limit, allrows );
|
||||||
|
|
||||||
// adjust limit in GUI
|
// adjust limit in GUI:
|
||||||
if limit <= 0 then
|
// Uncheck checkbox if calculated limit is larger than wanted rowcount
|
||||||
mainform.CheckBoxLimit.Checked := false
|
if (limit <= 0) and (AllRows > MakeInt(mainform.EditLimitEnd.Text)) then
|
||||||
else begin
|
mainform.CheckBoxLimit.Checked := false;
|
||||||
|
if limit > 0 then begin
|
||||||
mainform.CheckBoxLimit.Checked := true;
|
mainform.CheckBoxLimit.Checked := true;
|
||||||
tmpLimitStart := MakeInt(mainform.EditLimitStart.Text);
|
|
||||||
tmpLimitEnd := MakeInt(mainform.EditLimitEnd.Text);
|
|
||||||
if tmpLimitEnd > limit then
|
|
||||||
mainform.EditLimitEnd.Text := IntToStr(limit);
|
mainform.EditLimitEnd.Text := IntToStr(limit);
|
||||||
end;
|
end;
|
||||||
mainform.Repaint;
|
mainform.Repaint;
|
||||||
@ -4183,9 +4179,9 @@ end;
|
|||||||
Detect average row size and limit the number of rows fetched at
|
Detect average row size and limit the number of rows fetched at
|
||||||
once if more than ~ 5 MB of data
|
once if more than ~ 5 MB of data
|
||||||
}
|
}
|
||||||
function TMDIChild.GetCalculatedLimit( Table: String ): Int64;
|
procedure TMDIChild.GetCalculatedLimit(Table: String; out Limit, AllRows: Int64);
|
||||||
var
|
var
|
||||||
AvgRowSize, RecordCount : Int64;
|
AvgRowSize : Int64;
|
||||||
ds: TDataSet;
|
ds: TDataSet;
|
||||||
const
|
const
|
||||||
// how much overhead this application has per row
|
// how much overhead this application has per row
|
||||||
@ -4193,27 +4189,27 @@ const
|
|||||||
// average row size guess for mysql server < 5.0
|
// average row size guess for mysql server < 5.0
|
||||||
ROW_SIZE_GUESS: Integer = 2048;
|
ROW_SIZE_GUESS: Integer = 2048;
|
||||||
begin
|
begin
|
||||||
result := -1;
|
Limit := -1;
|
||||||
try
|
try
|
||||||
ds := GetResults('SHOW TABLE STATUS LIKE ' + esc(Table));
|
ds := GetResults('SHOW TABLE STATUS LIKE ' + esc(Table));
|
||||||
if ds = nil then exit;
|
if ds = nil then exit;
|
||||||
if ds.FieldByName('Avg_row_length').IsNull or ds.FieldByName('Rows').IsNull then begin
|
if ds.FieldByName('Avg_row_length').IsNull or ds.FieldByName('Rows').IsNull then begin
|
||||||
// Guessing row size and count for views, fixes bug #346
|
// Guessing row size and count for views, fixes bug #346
|
||||||
AvgRowSize := ROW_SIZE_GUESS + ROW_SIZE_OVERHEAD;
|
AvgRowSize := ROW_SIZE_GUESS + ROW_SIZE_OVERHEAD;
|
||||||
RecordCount := MaxInt;
|
AllRows := MaxInt;
|
||||||
end else begin
|
end else begin
|
||||||
AvgRowSize := MakeInt( ds.FieldByName( 'Avg_row_length' ).AsString ) + ROW_SIZE_OVERHEAD;
|
AvgRowSize := MakeInt( ds.FieldByName( 'Avg_row_length' ).AsString ) + ROW_SIZE_OVERHEAD;
|
||||||
RecordCount := MakeInt( ds.FieldByName( 'Rows' ).AsString );
|
AllRows := MakeInt( ds.FieldByName( 'Rows' ).AsString );
|
||||||
end;
|
end;
|
||||||
if AvgRowSize * RecordCount > prefLoadSize then
|
if AvgRowSize * AllRows > prefLoadSize then
|
||||||
begin
|
begin
|
||||||
result := Trunc( prefLoadSize / AvgRowSize );
|
Limit := Trunc( prefLoadSize / AvgRowSize );
|
||||||
if result >= RecordCount then result := -1;
|
if Limit >= AllRows then Limit := -1;
|
||||||
end;
|
end;
|
||||||
ds.Close;
|
ds.Close;
|
||||||
FreeAndNil(ds);
|
FreeAndNil(ds);
|
||||||
finally
|
finally
|
||||||
debug( 'GetCalculatedLimit: ' + formatnumber(result) );
|
debug( 'GetCalculatedLimit: ' + formatnumber(Limit) );
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -495,7 +495,7 @@ var
|
|||||||
extended_insert : Boolean;
|
extended_insert : Boolean;
|
||||||
max_allowed_packet : Int64;
|
max_allowed_packet : Int64;
|
||||||
thesevalues : String;
|
thesevalues : String;
|
||||||
valuescount, limit : Integer;
|
valuescount : Integer;
|
||||||
donext : Boolean;
|
donext : Boolean;
|
||||||
PBuffer : PChar;
|
PBuffer : PChar;
|
||||||
sql, current_characterset : String;
|
sql, current_characterset : String;
|
||||||
@ -504,7 +504,7 @@ var
|
|||||||
target_cliwa : Boolean;
|
target_cliwa : Boolean;
|
||||||
ansi : Boolean;
|
ansi : Boolean;
|
||||||
RecordCount_all, RecordCount_one, RecordNo_all,
|
RecordCount_all, RecordCount_one, RecordNo_all,
|
||||||
offset : Int64;
|
offset, limit : Int64;
|
||||||
sql_select : String;
|
sql_select : String;
|
||||||
cwin : TMDIChild;
|
cwin : TMDIChild;
|
||||||
query : TDataSet;
|
query : TDataSet;
|
||||||
@ -976,8 +976,7 @@ begin
|
|||||||
once if more than ~ 5 MB of data
|
once if more than ~ 5 MB of data
|
||||||
Be sure to do this step before the table is locked!
|
Be sure to do this step before the table is locked!
|
||||||
}
|
}
|
||||||
RecordCount_all := MakeInt( cwin.GetVar( 'SELECT COUNT(*) FROM ' + sourceMask(checkListTables.Items[i]) ) );
|
cwin.GetCalculatedLimit( checkListTables.Items[i], limit, RecordCount_all);
|
||||||
limit := cwin.GetCalculatedLimit( checkListTables.Items[i] );
|
|
||||||
|
|
||||||
if RecordCount_all = 0 then begin
|
if RecordCount_all = 0 then begin
|
||||||
if tofile then
|
if tofile then
|
||||||
|
Reference in New Issue
Block a user