I use oracle database 11.2.0.3 on WIN2008 Enterprise.
Oracle client 11.2.0.3
Delphi XE, Odac 8.01
I use devart component TOraQuery and TOraStoredProc
In both these components I call the same stored procedure with 2 parameters.
These are figures I get in v$mystat
NAME;STAT#;PROG;INFO2;BYTES
bytes sent via SQL*Net to client;589;Delphi;qry;125495;
bytes sent via SQL*Net to client;589;Delphi;stp;907115;
bytes received via SQL*Net from client;590;Delphi;qry;255233;
bytes received via SQL*Net from client;590;Delphi;stp;264213;
It is amazing there is almost 4 times more bytes returned than sent.
I expected way less bytes to be returned to the client.
Is there some properties I can switch off this returning of information ?
The data stream needs to go to the oracle, not return to client !
This is sql i used to create tables / sequences for this test:
Code: Select all
create table STPQRY (a number, b number);
create procedure stpins (in_a in number, in_b in number) as
begin
insert into stpqry (a, b) values (in_a, in_b);
end;
/
CREATE TABLE TESTDATA
(
INFO VARCHAR2(100 BYTE),
STAT# NUMBER,
VALUE NUMBER,
DT DATE,
SEQNR NUMBER,
PROG VARCHAR2(20 BYTE),
INFO2 VARCHAR2(20 BYTE)
);
create sequence testd_seq start with 1;
Code: Select all
unit uMain;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, Ora, DB, MemDS, DBAccess;
type
TfrmMain = class(TForm)
sess: TOraSession;
rgType: TRadioGroup;
btnStart: TButton;
lbInfo: TListBox;
Timer1: TTimer;
procedure btnStartClick(Sender: TObject);
private
fCountStp: Integer;
fCountQry: Integer;
procedure RunQuery;
procedure RunStp;
procedure AddStats(aTest, aSubTest, aProg: string);
public
constructor Create(AOwner: TComponent); override;
end;
var
frmMain: TfrmMain;
implementation
uses StrUtils;
{$R *.dfm}
procedure TfrmMain.AddStats(aTest, aSubTest, aProg: string);
var qry: TOraQuery;
begin
qry := TOraQuery.Create(Self);
try
qry.SQL.Text :=
'insert into testdata (seqnr, info, info2, prog, stat#, value, dt) '+
'select testd_seq.nextval, :aTEST, :aSubTest, :aProg, statistic#, value, sysdate '+
'from v$mystat where statistic# in (589, 590)';
qry.ParamByName('aTest').AsString := aTest;
qry.ParamByName('aSubTest').AsString := aSubTest;
qry.ParamByName('aProg').AsString := aProg;
qry.ExecSQL;
finally
qry.Free;
end;
end;
procedure TfrmMain.btnStartClick(Sender: TObject);
var aTest: string;
I: Integer;
begin
aTest := IfThen(rgType.ItemIndex = 0, 'qry', 'stp');
AddStats('begin test', aTest, 'Delphi');
for I := 1 to 1000 do
begin
if rgType.ItemIndex = 0 then // run query
RunQuery
else
RunStp;
end;
lbInfo.Items.Values['QRY Count'] := IntToStr(fCountQry);
lbInfo.Items.Values['STP Count'] := IntToStr(fCountStp);
AddStats('end test', aTest, 'Delphi');
end;
constructor TfrmMain.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
fCountStp := 0;
fCountQry := 0;
sess.Connect;
end;
procedure TfrmMain.RunQuery;
var qry: TOraQuery;
begin
inc(fCountQry);
qry := TOraQuery.Create(Self);
try
qry.Session := sess;
qry.SQL.Clear;
Qry.SQL.Add('BEGIN');
qry.SQL.Add(' -- query method');
qry.SQL.Add(' STPINS(:IN_A, :IN_B); ');
qry.SQL.Add('END;');
qry.ParamByName('IN_A').AsFloat := Random(1000);
qry.ParamByName('IN_B').AsFloat := Random(1000);
qry.ExecSQL;
finally
qry.Free;
end;
end;
procedure TfrmMain.RunStp;
var stp: TOraStoredProc;
begin
inc(fCountStp);
stp := TOraStoredProc.Create(Self);
try
stp.Session := sess;
stp.StoredProcName := 'STPINS';
stp.Prepare;
stp.ParamByName('IN_A').AsFloat := Random(1000);
stp.ParamByName('IN_B').AsFloat := Random(1000);
stp.ExecProc;
finally
stp.Free;
end;
end;
end.
Code: Select all
object frmMain: TfrmMain
Left = 0
Top = 0
Caption = 'Stored Procedure VERSUS Query'
ClientHeight = 303
ClientWidth = 538
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object rgType: TRadioGroup
Left = 32
Top = 64
Width = 185
Height = 105
Caption = 'rgType'
ItemIndex = 0
Items.Strings = (
'Query'
'Stored procedure')
TabOrder = 0
end
object btnStart: TButton
Left = 32
Top = 9
Width = 75
Height = 25
Caption = 'Start'
TabOrder = 1
OnClick = btnStartClick
end
object lbInfo: TListBox
Left = 272
Top = 32
Width = 209
Height = 209
ItemHeight = 13
TabOrder = 2
end
object sess: TOraSession
Username = 'username'
Password = 'password'
Server = 'alias'
LoginPrompt = False
Left = 136
Top = 216
end
end
Code: Select all
select n.name, t.stat#, t.prog, t.info2, max(t.value) - min(t.value) bytes
from testdata t, v$statname n
where t.stat# = n.statistic#
group by t.stat#, t.prog, t.info2, n.name
order by stat#,bytes;