Skip to content

FirebirdSql.Data.FirebirdClient - Possible performance issue #1181

@DerMagereStudent

Description

@DerMagereStudent

Describe your issue

Is there a way to improve the performance of the ORM mapper of Linq2Db using the FirebirdDataProvider. I retrieve 1831 records from a table having 39 columns (all INTEGER, DECIMAL(13,5) and 2x VARCHAR(100)). The longest varchar is 37 chars. Approximately 60% of all the values are null. I compared the raw execution with the mapper execution of Linq2Db using this code:

var query = (
    from cd in this.dbCaps.CapsDepts
    join c in this.dbCaps.CAPS on cd.CapId equals c.CapId
    where deptIds.Contains(cd.DeptId)
    select c
).Distinct();

var sw = Stopwatch.StartNew();
var cmd = this.dbCaps.CreateCommand();
cmd.CommandText = query.ToString();
using (var reader = cmd.ExecuteReader())
{
    var values = new object[reader.FieldCount];
    while (reader.Read())
    {
        reader.GetValues(values);
    }
}
sw.Stop();
Console.WriteLine($"Raw Time: {sw.ElapsedMilliseconds} ms");

sw.Restart();
var result = await query.ToListAsync();
sw.Stop();
Console.WriteLine($"With Mapping Time: {sw.ElapsedMilliseconds} ms");

Here is the result:

Raw Time: 1579 ms
With Mapping Time: 1682 ms

Raw Time: 1710 ms
With Mapping Time: 1904 ms

Raw Time: 1701 ms
With Mapping Time: 1885 ms

Raw Time: 1695 ms
With Mapping Time: 1797 ms

The problem is I also tested the code on my colleagues computer. Here is the result:

Raw Time: 6819 ms
With Mapping Time: 6954 ms

Raw Time: 6868 ms
With Mapping Time: 6851 ms

Raw Time: 6784 ms
With Mapping Time: 6842 ms

Raw Time: 6729 ms
With Mapping Time: 6950 ms

We both access the same database server. The network is also not the bottleneck. So it should be a client side problem. The table size (based on RDB$RELATION_FIELDS.RDB$FIELD_LENGTH) is ~4MB, for 2106 records with all values NOT NULL. But as I already mentioned about 60% of the values are null. Handling less than 4MB should not take 7 seconds.

Environment details

PC specs:

  • i7-13700K
  • 64GB 4000MHz

Colleagues specs:

  • i7-11850H
  • 64GB 3200MHz

Database (with version): Firebird 3.0.9

ADO.NET Provider (with version): FirebirdSql.Data.FirebirdClient - tried 9.9.1 and 10.3.1

Operating system: Windows 11 23H2

.NET Version: Tried net7 and net8

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions