First try of noprefetch

Hello. All.
It’s a draft for testing only.

Problems:

  1. All this about perfomance.
  2. DBIx::SearchBuilder fetch all fields from target table. We can
    reproduce this at ticket history when ticket contain large binary
    attachments. Their content fetched within first request, but never used.
  3. DBIx::SearchBuilder have no info about table structure so don’t know
    field list.

Solution:
Attached patches against
rt3.0.8pre2
DBIx::SearchBuilder 0.94
solve 2) and 3) in one way.
This patches are easy to understand:

  1. New function ‘FetchFields’ in DBIx::SearchBuilder class which should
    return list of fields to prefetch while filling collection of records.
    By default return [’*’].
    Caveat: list must include ‘id’ field.

  2. Functions which update {‘values’} hash of record instance also update
    {‘fetched’} hash.

  3. __Value function changed to check {‘fetched’} hash and fetch field
    from DB if it’s needed.

  4. To _ClassAccessible hash added attribute ‘noprefetch’. That used when
    Record loaded not via LoadFromHash(means external source
    DBIx::SearchBuilder).

  5. Several other changes. It’s easier to look in path. I know perl
    better then English :slight_smile:

Why RT changed?

  1. RT::CurrentUser: _Accessible converted to _ClassAccessible.
    As I’ve understood _Accessible is deprecated. Code don’t work if class
    don’t have _ClassAccessible sub. I can fix it I think.

  2. Features are implemented in RT::Attachments.

  3. RT/Ticket_Overlay.pm have some strange field ‘Requestors’, that don’t
    have mirror in DB. I think it should be eliminated. It’s minor ‘bug’.

Questions:

  1. Reasons for keeping _ClassAccessible in Overlays?

  2. Why sometime id skipped there?

  3. Comments? Suggestions? I can maintain and improve this patches only
    if there is any sanity chance to include it main code in other case I
    just throw them away.

    RT is good. I want to see RT on first place :slight_smile:
    Ruslan.

noprefetch.patch (5.64 KB)

noprefetch_rt.patch (4.24 KB)

  1. New function ‘FetchFields’ in DBIx::SearchBuilder class which should
    return list of fields to prefetch while filling collection of records.
    By default return [’*’].
    Caveat: list must include ‘id’ field.

I have made a similar effort, by implementing the

$sb->Columns

call at runtime to dictate what fields must be fetched during the
next query. This strikes me as better because even for the same
classes, different pages may require different fields to be fetched.

My SearchBuilder_Vendor.pm is attached below. Maybe we can merge
my ->Columns API with your lazy fetching mechanism?

Thanks,
/Autrijus/

SearchBuilder_Vendor.pm (4.48 KB)