NETProvider icon indicating copy to clipboard operation
NETProvider copied to clipboard

DataReader->Read speed very slow

Open Zeki-Gursoy opened this issue 5 months ago • 2 comments

Because I found the read speed slow in Firebird, I tested it with other databases.

The read speed results for a single-column table with 10M records were as follows:

  • Npgsql (Postgresql): 3-4 seconds.
  • SqlClient (MS): 8-9 seconds.
  • FbClient & Fb ODBC: 35-40 seconds.

I'd like to know if this significant difference is due to a parameter in FbClient or to the Firebird core.

Firebird 5.0.3, FbClient 10.3.3, FbODBC 3.0.1.20 on local machine.

Zeki-Gursoy avatar Sep 17 '25 19:09 Zeki-Gursoy

It's hard to provide any guidance without seeing the actual code...

cincuranet avatar Sep 17 '25 19:09 cincuranet

It's hard to provide any guidance without seeing the actual code...

OK, please use...

DDL:

create database 'c:\users\zg\desktop\testdb.fdb'
  user 'SYSDBA'
  password '1'
  page_size = 8192
  default character set none
  collation none;

create table "testtable" (
  "testfield" integer);

execute block
as
declare i int = 1;
begin
	while(i <= 10000000) do
	begin
		insert into "testtable"("testfield") values(:i);
		i = i + 1;
	end
end

C#

private void button1_Click(object sender, EventArgs e)
{
    var csb = new FbConnectionStringBuilder()
    {
        Database = @"c:\users\zeki\desktop\testdb.fdb",
        DataSource = "localhost",
        UserID = "SYSDBA",
        Password = "1"
    };

    var cn = new FbConnection(csb.ConnectionString);
    var cmd = new FbCommand(@"select ""testfield"" from ""testtable"" ", cn);
    cn.Open();

    var rdr = cmd.ExecuteReader();

    var sw = new Stopwatch();
    sw.Start();

    while (rdr.Read())
    {
        _ = rdr.GetInt32(0);
    }

    sw.Stop();

    rdr.Close();
    cmd.Dispose();
    cn.Close();

    MessageBox.Show(sw.Elapsed.Seconds.ToString());
}

Zeki-Gursoy avatar Sep 17 '25 22:09 Zeki-Gursoy