• GilaMonster (7/9/2014)


    Jack Corbett (7/9/2014)


    1. Scaling - ORM tools still aren't very good at complex SQL (multiple joins, outer joins, etc...) so you need to evaluate every query that EF is sending and be ready to replace "bad" queries with stored procedures.

    2. Tight coupling - if you really want to take full advantage of EF or any other ORM toll it means that you are tightly coupling the data access layer to your database. That means you are stuck with a specific database design until you can change the application as well. Whereas a design that provides an "API" to the database via views/functions/procedures allows you to change the underlying schema of the database as long as your API presents the same shape data to the application.

    3. Tuning - if there is a poorly performing query there is little you can do to tune it. The SQL is generated so, AFAIK, you can't provide hints (OPTION (RECOMPILE) to help with "bad" parameter sniffing) or re-shape it to get a different plan.

    Agreed on all points. I'm busy tuning a system which uses EF and thousand line long SQL statements are the norm, queries which fetch every column from the table, queries which fetch every row from multiple tables in a set of UNIONS, etc. Half the queries all I can do is send them to the dev and ask what the point is and whether they can be moved to stored procs.

    EF is fine for simple queries. Sure beats writing a few hundred CRUD procedures.

    I also had the chance to tune EF systems. Same as you describe.

    Because I didn't want to ask for many of the queries I realized that extending some of the non-clustered indexes have brought a lot of improvement for bunch of queries.

    Anyway there is an "optimize for ad hoc workloads" option. It enables query plans to use less memory when cached.

    Igor Micev,My blog: www.igormicev.com