Stored Procedure or calculations via IQueryable?

Posted by Shawn Mclean on Stack Overflow See other posts from Stack Overflow or by Shawn Mclean
Published on 2010-12-31T20:42:10Z Indexed on 2010/12/31 20:54 UTC
Read the original article Hit count: 204

This is a question that is based on choosing performance over design practices. If I have a method that will be executed many times a second;

public static IQueryable<IPerson> InRadius(this IQueryable<IPerson> query, Coordinate center, double radius)
{
    return (from u in query
            where CallHeavyMathFormula(u, center, radius)
            select u);
}

This extension method for IQueryable generates a SQL that does some heavy maths calculation (Cosine, Sine, etc). This would mean the application sends 1-2KB of sql to the server per call.

I've heard of placing all application logic, in your application. I also would like to change to a database such as azure or one of those scalable databases in the future. How do I handle something like this? Should I leave it as it is now or write stored procedures? How do applications like twitter or facebook do it?

© Stack Overflow or respective owner

Related posts about database

Related posts about design-patterns