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

SubSonic Linq Slow? #258

Open
toptensoftware opened this issue Mar 17, 2011 · 1 comment
Open

SubSonic Linq Slow? #258

toptensoftware opened this issue Mar 17, 2011 · 1 comment

Comments

@toptensoftware
Copy link

We're trying to sort out why some of our web pages are burning so much CPU and seem to have narrowed it down to SubSonic's LINQ implementation.

Using the standard T4 templates (although probably somewhat older version of the templates) I've found that running a simple SingleOrDefault query can be about 20x times slower than an equivalent CodingHorror query.

myrecord.SingleOrDefault(x=>x.name=="blah") = 200,000 ticks

CodingHorror("SELECT * FROM myrecords WHERE name=@p", "blah).ExecuteTypedList()[0] = 10,000 ticks.

This seems a pretty harsh performance hit and I'm wondering if this is typical and has it been improved in later versions of SubSonic (we're using a somewhat older build because we can't get the latest to work).

btw: Also, I found that I could improve SingleOrDefault in the generated template by replacing the Count() and ExecuteTypedList() with results.SingleOrDefault(). This took about 100,000 ticks.

We're running under .NET/Windows/MySQL.

@toptensoftware
Copy link
Author

Profiler is pointing at this in ExecutionBuilder.cs:

// this sucks, but since we don't track true SQL types through the query, and ADO throws exception if you
// call the wrong accessor, the best we can do is call GetValue and Convert.ChangeType
Expression value = Expression.Convert(
    Expression.Call(typeof (Convert), "ChangeType", null,
                    Expression.Call(reader, "GetValue", null, Expression.Constant(iOrdinal)),
                    Expression.Constant(TypeHelper.GetNonNullableType(column.Type), typeof(Type))
        ),
    column.Type
    );

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

1 participant