Is it possible to collect object usage information during compilation?

Martin Nowak via Digitalmars-d digitalmars-d at puremagic.com
Sat Jan 10 05:19:01 PST 2015


On 01/10/2015 01:52 PM, Jacob Carlborg wrote:
> On 2015-01-10 13:36, Martin Nowak wrote:
>
>> The idea isn't bad, but the performance will suck. This is generally
>> known as N+1 query, only that this is even worse, as each field is
>> queried individually.
>
> Since the "all" method was called I would assume all rows in the person
> table are fetched in one single query. Although I don't know if that
> will work if not the whole row should be loaded.

For row or document oriented databases you want to query all fields in 
parallel. For columnar stores it might be possible to efficiently query 
specific fields for many documents.

>
>> Here is a sketch for an optimal solution. I'm actually eagerly waiting
>> that someone finally implements it.
>>
>> http://dpaste.dzfl.pl/cd375ac594cf
>
> How would you handled fetching multiple rows and a foreach loop, i.e. my
> example?

I'd simple produce multiple rows, the principle remains the same.

> Perhaps a detail but using a wrapped type instead of the raw types in
> Person you could handle things like null in the database.
>
The example already uses Variant.


More information about the Digitalmars-d mailing list