Curious about Excluded Fields

Posts   
 
    
simmotech
User
Posts: 1024
Joined: 01-Feb-2006
# Posted on: 08-Sep-2017 08:48:47   

I was just curious about the reason behind fetch queries using "NULL AS [xxx]" for excluded fields.

I guess it was to have a one to one with the entity fields into which the results will go but wouldn't it be just as easy to exclude those fields from the query and match returned results by field name?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 08-Sep-2017 10:01:41   

It's an optimization trick simple_smile We had what you suggest before, I think before 4.2, not sure, but then the resultsets are different if you do or don't exclude fields. That would mean to materialize an entity we needed to read/write each field value individually (as it could be on a different ordinal in the row).

By returning NULL for an excluded field, the resultsets for a query with and without excluded fields is the same, so we can then simply pull the full row from the datareader and store it in the entity in 1 go. This is much faster than reading fields individually simple_smile

Frans Bouma | Lead developer LLBLGen Pro