Remove no longer needed routine for autocalculating row limit: GetCalculatedLimit. The Export SQL dialog now uses a constant number of 5000 rows fetched per step. Also removes the option in the preferences screen for limiting the data amount, which was misleading the user before and only used to limit the export stuff.

This commit is contained in:
Ansgar Becker
2008-08-26 09:09:41 +00:00
parent e2b67b5831
commit 2cff5732fc
5 changed files with 5 additions and 84 deletions

View File

@ -58,8 +58,6 @@ const
DEFAULT_DATALIMITEND = 5000;
// how much memory we're aiming to use for the
// data grid and it's automatic limit function
REGNAME_LOADSIZE = 'DataLoadSize';
DEFAULT_LOADSIZE = 5*1024*1024;
REGNAME_LOGSQLNUM = 'logsqlnum';
DEFAULT_LOGSQLNUM = 300;
REGNAME_LOGSQLWIDTH = 'logsqlwidth';

View File

@ -377,7 +377,6 @@ type
procedure GridPaintText(Sender: TBaseVirtualTree; const TargetCanvas:
TCanvas; Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType);
procedure menuDeleteSnippetClick(Sender: TObject);
procedure GetCalculatedLimit(Table: String; out Limit, AllRows: Int64);
procedure menuExploreClick(Sender: TObject);
procedure menuInsertSnippetAtCursorClick(Sender: TObject);
procedure menuLoadSnippetClick(Sender: TObject);
@ -505,8 +504,7 @@ type
prefConvertHTMLEntities : Boolean;
prefLogsqlnum,
prefLogSqlWidth,
prefDefaultColWidth,
prefLoadSize : Integer;
prefDefaultColWidth : Integer;
prefCSVSeparator,
prefCSVEncloser,
prefCSVTerminator : String[10];
@ -868,7 +866,6 @@ begin
prefCSVTerminator := Mainform.GetRegValue(REGNAME_CSV_TERMINATOR, DEFAULT_CSV_TERMINATOR);
prefRememberFilters := Mainform.GetRegValue(REGNAME_REMEMBERFILTERS, DEFAULT_REMEMBERFILTERS);
prefPreferShowTables := Mainform.GetRegValue(REGNAME_PREFER_SHOWTABLES, DEFAULT_PREFER_SHOWTABLES);
prefLoadSize := Mainform.GetRegValue(REGNAME_LOADSIZE, DEFAULT_LOADSIZE);
// SQL-Font:
fontname := Mainform.GetRegValue(REGNAME_FONTNAME, DEFAULT_FONTNAME);
@ -3739,45 +3736,6 @@ begin
end;
{***
Detect average row size and limit the number of rows fetched at
once if more than ~ 5 MB of data
}
procedure TMDIChild.GetCalculatedLimit(Table: String; out Limit, AllRows: Int64);
var
AvgRowSize : Int64;
ds: TDataSet;
const
// how much overhead this application has per row
ROW_SIZE_OVERHEAD : Integer = 1150;
// average row size guess for mysql server < 5.0
ROW_SIZE_GUESS: Integer = 2048;
begin
Limit := -1;
try
ds := GetResults('SHOW TABLE STATUS LIKE ' + esc(Table));
if ds = nil then exit;
if ds.FieldByName('Avg_row_length').IsNull or ds.FieldByName('Rows').IsNull then begin
// Guessing row size and count for views, fixes bug #346
AvgRowSize := ROW_SIZE_GUESS + ROW_SIZE_OVERHEAD;
AllRows := MaxInt;
end else begin
AvgRowSize := MakeInt( ds.FieldByName( 'Avg_row_length' ).AsString ) + ROW_SIZE_OVERHEAD;
AllRows := MakeInt( ds.FieldByName( 'Rows' ).AsString );
end;
if AvgRowSize * AllRows > prefLoadSize then
begin
Limit := Trunc( prefLoadSize / AvgRowSize );
if Limit >= AllRows then Limit := -1;
end;
ds.Close;
FreeAndNil(ds);
finally
debug( 'GetCalculatedLimit: ' + formatnumber(Limit) );
end;
end;
{**
Column selection for datagrid
}

View File

@ -973,12 +973,10 @@ begin
end;
end;
{***
Detect average row size and limit the number of rows fetched at
once if more than ~ 5 MB of data
Be sure to do this step before the table is locked!
}
cwin.GetCalculatedLimit( checkListTables.Items[i], limit, RecordCount_all);
// Set rows per step limit and detect total row count
// Be sure to do this step before the table is locked!
limit := 5000;
RecordCount_all := MakeInt(cwin.GetNamedVar('SHOW TABLE STATUS LIKE '+esc(checkListTables.Items[i]), 'Rows'));
if RecordCount_all = 0 then begin
if tofile then

View File

@ -445,13 +445,6 @@ object optionsform: Toptionsform
Height = 13
Caption = 'Maximum column-width in data-grids:'
end
object lblLoadSize: TLabel
Left = 8
Top = 58
Width = 196
Height = 13
Caption = 'Data size for auto calculating LIMIT [KB]:'
end
object GroupBox2: TGroupBox
Left = 0
Top = 80
@ -561,26 +554,6 @@ object optionsform: Toptionsform
TabOrder = 0
OnClick = Modified
end
object editLoadSize: TEdit
Left = 219
Top = 55
Width = 42
Height = 21
TabOrder = 4
Text = '1'
end
object updownLoadSize: TUpDown
Left = 261
Top = 55
Width = 17
Height = 21
Associate = editLoadSize
Min = 1
Max = 32767
Position = 1
TabOrder = 5
Wrap = True
end
end
object TabSheet5: TTabSheet
BorderWidth = 5

View File

@ -92,9 +92,6 @@ type
updownUpdatecheckInterval: TUpDown;
chkPreferShowTables: TCheckBox;
chkUpdateCheckBuilds: TCheckBox;
lblLoadSize: TLabel;
editLoadSize: TEdit;
updownLoadSize: TUpDown;
procedure ButtonCancelClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Modified(Sender: TObject);
@ -176,7 +173,6 @@ begin
reg.WriteBool(REGNAME_DO_UPDATECHECK_BUILDS, chkUpdatecheckBuilds.Checked);
reg.WriteInteger(REGNAME_UPDATECHECK_INTERVAL, updownUpdatecheckInterval.Position);
reg.WriteBool(REGNAME_PREFER_SHOWTABLES, chkPreferShowTables.Checked);
reg.WriteInteger(REGNAME_LOADSIZE, updownLoadSize.Position*SIZE_KB);
// Clean registry from unwanted WHERE clauses if "Remember WHERE filters" was unchecked
if not chkRememberFilters.Checked then begin
@ -235,7 +231,6 @@ begin
cwin.prefCSVTerminator := self.Edit3.text;
cwin.prefConvertHTMLEntities := self.CheckBoxConvertHTMLEntities.Checked;
cwin.prefPreferShowTables := chkPreferShowTables.Checked;
cwin.prefLoadSize := updownLoadSize.Position * SIZE_KB;
end;
// Settings have been applied, send a signal to the user
@ -284,7 +279,6 @@ begin
updownUpdatecheckInterval.Position := Mainform.GetRegValue(REGNAME_UPDATECHECK_INTERVAL, DEFAULT_UPDATECHECK_INTERVAL);
chkUpdatecheckClick(Sender);
chkPreferShowTables.Checked := Mainform.GetRegValue(REGNAME_PREFER_SHOWTABLES, DEFAULT_PREFER_SHOWTABLES);
updownLoadSize.Position := Mainform.GetRegValue(REGNAME_LOADSIZE, DEFAULT_LOADSIZE) div SIZE_KB;
// Default Column-Width in DBGrids:
updownDefaultColWidth.Position := Mainform.GetRegValue(REGNAME_DEFAULTCOLWIDTH, DEFAULT_DEFAULTCOLWIDTH);