Profiling our ORM



  • SELECT [GroupBy1].[A1] AS [C1]
    FROM (
    SELECT COUNT(1) AS A1
    FROM (Select 1 AS X) AS [SingleRowTable1]
    WHERE 1 = 0
    )
    AS [GroupBy1]



  • @Julia said:

    WHERE 1 = 0
     

    It's called Object Reality Mapping


  • Considered Harmful

    @dhromed said:

    @Julia said:

    WHERE 1 = 0
     

    It's called Object Reality Mapping


    I know LINQ-to-SQL (and probably its derivatives) would throw in a 1 = 0 if its static analysis indicated the query could never return results.



  • @joe.edwards said:

    I know LINQ-to-SQL (and probably its derivatives) would throw in a 1 = 0 if its static analysis indicated the query could never return results.
     

    What is the point in constructing a query, passing it around, activating the lower levels of your library and god knows what else (does it send the statement to the DB?), if you know you won't get any data? Wouldn't it be better to just return an empty dataset?

    Yeah, ok, the optimizer is probably required to always return some kind of query, so that the rest of the library can send it to the DB... And the DB will have a much easier time creating a null dataset by readding that 1 = 0 than by analysing everything again... But a WTF it is. And the WTF is probably that requirement that the optimizer must always return a query.



  • @Mcoder said:

    @joe.edwards said:

    I know LINQ-to-SQL (and probably its derivatives) would throw in a 1 = 0 if its static analysis indicated the query could never return results.
     

    What is the point in constructing a query, passing it around, activating the lower levels of your library and god knows what else (does it send the statement to the DB?), if you know you won't get any data? Wouldn't it be better to just return an empty dataset?

    Yeah, ok, the optimizer is probably required to always return some kind of query, so that the rest of the library can send it to the DB... And the DB will have a much easier time creating a null dataset by readding that 1 = 0 than by analysing everything again... But a WTF it is. And the WTF is probably that requirement that the optimizer must always return a query.

    I would do something like that if I needed to get the query signature to design a quick report and the report designer does not support SET calls or multi-query batches.


Log in to reply