From: Berko B. <vb...@ma...> - 2017-02-23 08:16:20
|
<html><head></head><body><div style="font-family: Verdana;font-size: 12.0px;"><div> <div>Hi,</div> <div>I have a problem with performance of firebird net provider.</div> <div>My query is slow.</div> <div>In my table there are ~ 5000 records.</div> <div>Simple query: select * from table</div> <div> </div> <div>In case of IBExpert or Delphi program, it takes ~ 80 ms</div> <div>In case of C# ~ 250 ms</div> <div>I fetch all records in IBExpert and Delphi too.</div> <div>I have tried on local database and on networking db. No Difference.</div> <div>My environment:</div> <div>- Windows 7 64.</div> <div>- Firebird Superserver 2.5.7</div> <div>- Net provider 5.7</div> <div> </div> <div>I feel, the number of records (or number of varchar columns) grows, so does the difference between C# and Delphi.</div> <div> </div> <div>My DB Script:</div> <div>------------------</div> <div> <div>SET SQL DIALECT 3;</div> <div>CREATE DATABASE '127.0.0.1:c:\test\test.fdb'<br/> USER 'user' PASSWORD 'password'<br/> PAGE_SIZE 8192;</div> <div><br/> CREATE TABLE TEST (<br/> I0 INTEGER NOT NULL,<br/> C1 CHAR(10),<br/> F1 VARCHAR(120),<br/> F2 VARCHAR(120),<br/> F3 VARCHAR(120),<br/> F4 VARCHAR(120)<br/> );<br/> COMMIT WORK;<br/> ALTER TABLE TEST ADD CONSTRAINT PK_TEST PRIMARY KEY (I0);<br/> commit work;<br/> set term ^ ;<br/> execute block<br/> as<br/> declare variable i integer;<br/> declare variable par varchar(120);<br/> begin<br/> i=1;<br/> par='aaaaaaaaaaaaaaaaaaaaxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxyyyyyyyyyyyyyyyyyyyyHHHHHHHHHH';<br/> while (i<5000) do<br/> begin<br/> insert into test(i0,c1,f1,f2,f3,f4) values (:i,trim(cast(:i as varchar(5)))||'_ID',:par, :par,:par, :par);<br/> i=i+1;<br/> end</div> <div>end^<br/> set term ; ^</div> <div>commit work;</div> </div> <div> </div> <div>C# program:</div> <div>------------------</div> <div> <div> string cs =<br/> @"User = user; Password=password;Database=c:\test\test.fdb;DataSource=127.0.0.1"<br/> + ";Port=3050;Dialect=3;Role=;Connection lifetime = 15; "<br/> + "Pooling=false;Packet Size = 8192; ServerType=0;";</div> <div> var con = new FbConnection(cs);<br/> con.Open();<br/> var watch = System.Diagnostics.Stopwatch.StartNew();<br/> FbCommand com = new FbCommand("select i0,c1,f1,f2,f3,f4 from test", con);<br/> var dr = com.ExecuteReader();<br/> while (dr.Read()) ;<br/> watch.Stop();<br/> var elapsedMs = watch.ElapsedMilliseconds;<br/> Console.WriteLine(elapsedMs.ToString());<br/> com.Dispose();<br/> con.Dispose();</div> <div> </div> </div> </div></div></body></html> |
From: Berko B. <vb...@ma...> - 2017-02-23 08:26:09
|
Hi, I terrible sorry of previous mail format. I try it again in plain text. I have a problem with performance of firebird net provider. My query is slow. In my table there are ~ 5000 records. Simple query: select * from table In case of IBExpert or Delphi program, it takes ~ 80 ms In case of C# ~ 250 ms I fetch all records in IBExpert and Delphi too. I have tried on local database and on networking db. No Difference. My environment: - Windows 7 64. - Firebird Superserver 2.5.7 - Net provider 5.7 I feel, the number of records (or number of varchar columns) grows, so does the difference between C# and Delphi. My DB Script: ------------------ SET SQL DIALECT 3; CREATE DATABASE '127.0.0.1:c:\test\test.fdb' USER 'user' PASSWORD 'password' PAGE_SIZE 8192; CREATE TABLE TEST ( I0 INTEGER NOT NULL, C1 CHAR(10), F1 VARCHAR(120), F2 VARCHAR(120), F3 VARCHAR(120), F4 VARCHAR(120) ); COMMIT WORK; ALTER TABLE TEST ADD CONSTRAINT PK_TEST PRIMARY KEY (I0); commit work; set term ^ ; execute block as declare variable i integer; declare variable par varchar(120); begin i=1; par='aaaaaaaaaaaaaaaaaaaaxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxyyyyyyyyyyyyyyyyyyyyHHHHHHHHHH'; while (i<5000) do begin insert into test(i0,c1,f1,f2,f3,f4) values (:i,trim(cast(:i as varchar(5)))||'_ID',:par, :par,:par, :par); i=i+1; end end^ set term ; ^ commit work; C# program: ------------------ string cs = @"User = user; Password=password;Database=c:\test\test.fdb;DataSource=127.0.0.1" + ";Port=3050;Dialect=3;Role=;Connection lifetime = 15; " + "Pooling=false;Packet Size = 8192; ServerType=0;"; var con = new FbConnection(cs); con.Open(); var watch = System.Diagnostics.Stopwatch.StartNew(); FbCommand com = new FbCommand("select i0,c1,f1,f2,f3,f4 from test", con); var dr = com.ExecuteReader(); while (dr.Read()) ; watch.Stop(); var elapsedMs = watch.ElapsedMilliseconds; Console.WriteLine(elapsedMs.ToString()); com.Dispose(); con.Dispose(); |
From: Jiří Č. <ji...@ci...> - 2017-02-23 08:32:03
|
> I feel, the number of records (or number of varchar columns) grows, so > does the difference between C# and Delphi. You feel or can you confirm it? Did you tried i.e. selecting just NULL? -- Mgr. Jiří Činčura Independent IT Specialist |
From: Berko B. <vb...@ma...> - 2017-02-23 09:43:41
|
> > I feel, the number of records (or number of varchar columns) grows, so > > does the difference between C# and Delphi. > > You feel or can you confirm it? Did you tried i.e. selecting just NULL? I set null the F1-F5 fields, i get test result: C# : ~ 110 ms Delphi: ~ 50 ms So the difference between C# and Delphi decrease. Berko |
From: Jiří Č. <ji...@ci...> - 2017-02-23 10:04:05
|
How the Delphi code looks like? -- Mgr. Jiří Činčura Independent IT Specialist |
From: Berko B. <vb...@ma...> - 2017-02-23 10:52:24
|
My Delphi Code: db.Open; Query.Transaction.StartTransaction; d1:=now; Query.SQL.Text:='select i0,c1,f1,f2,f3,f4 from test'; Query.Open; while not Query.Eof do begin if (Query.FieldByName('I0').AsInteger<0) or (Query.FieldByName('C1').AsString='???') or (Query.FieldByName('F1').AsString='???') or (Query.FieldByName('F2').AsString='???') or (Query.FieldByName('F3').AsString='???') or (Query.FieldByName('F4').AsString='???') then Caption:='ok'; Query.Next; end; d2:=now; showmessage(inttostr(Query.RecordCount)+':'+inttostr(MilliSecondsBetween(d2,d1))); Tran.Commit; |