Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FirebirdSql.Data.FirebirdClient - Possible performance issue #1181

Open
DerMagereStudent opened this issue Jun 27, 2024 · 1 comment
Open

Comments

@DerMagereStudent
Copy link

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

@Aytharn
Copy link

Aytharn commented Oct 3, 2024

it looks just sluggish to me in general, compared to other providers like MySQL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants