Skip to content

Commit 5d51bdb

Browse files
committed
Lazy load big text columns
The only exception is Content in RT::Configuration, considering we nearly always need to access the Content when loading configurations.
1 parent c7d0134 commit 5d51bdb

11 files changed

Lines changed: 39 additions & 20 deletions

File tree

lib/RT/Attachment.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,9 +1329,9 @@ sub _CoreAccessible {
13291329
ContentEncoding =>
13301330
{read => 1, write => 1, sql_type => 12, length => 80, is_blob => 0, is_numeric => 0, type => 'varchar(80)', default => ''},
13311331
Content =>
1332-
{read => 1, write => 1, sql_type => -4, length => 0, is_blob => 1, is_numeric => 0, type => 'longblob', default => ''},
1332+
{read => 1, write => 1, sql_type => -4, length => 0, is_blob => 1, is_numeric => 0, type => 'longblob', default => '', lazy_load => 1},
13331333
Headers =>
1334-
{read => 1, write => 1, sql_type => -4, length => 0, is_blob => 1, is_numeric => 0, type => 'longtext', default => ''},
1334+
{read => 1, write => 1, sql_type => -4, length => 0, is_blob => 1, is_numeric => 0, type => 'longtext', default => '', lazy_load => 1},
13351335
Creator =>
13361336
{read => 1, auto => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => '0'},
13371337
Created =>

lib/RT/Attribute.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ sub _CoreAccessible {
767767
Description =>
768768
{read => 1, write => 1, sql_type => 12, length => 255, is_blob => 0, is_numeric => 0, type => 'varchar(255)', default => ''},
769769
Content =>
770-
{read => 1, write => 1, sql_type => -4, length => 0, is_blob => 1, is_numeric => 0, type => 'blob', default => ''},
770+
{read => 1, write => 1, sql_type => -4, length => 0, is_blob => 1, is_numeric => 0, type => 'blob', default => '', lazy_load => 1},
771771
ContentType =>
772772
{read => 1, write => 1, sql_type => 12, length => 16, is_blob => 0, is_numeric => 0, type => 'varchar(16)', default => ''},
773773
ObjectType =>

lib/RT/Migrate/Serializer.pm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ sub PushCollections {
257257
my $collection = $class->new( RT->SystemUser );
258258
$collection->FindAllRows if $self->{FollowDisabled};
259259
$collection->CleanSlate; # some collections (like groups and users) join in _Init
260+
$collection->SelectAllColumns(1);
260261
$collection->UnLimit;
261262
$collection->OrderBy( FIELD => 'id' );
262263

@@ -332,6 +333,7 @@ sub PushBasics {
332333

333334
# Global attributes
334335
my $attributes = RT::Attributes->new( RT->SystemUser );
336+
$attributes->SelectAllColumns(1);
335337
$attributes->LimitToObject( $RT::System );
336338
$self->PushObj( $attributes );
337339

@@ -349,9 +351,11 @@ sub PushBasics {
349351
# Global scrips
350352
if ($self->{FollowScrips}) {
351353
my $scrips = RT::Scrips->new( RT->SystemUser );
354+
$scrips->SelectAllColumns(1);
352355
$scrips->LimitToGlobal;
353356

354357
my $templates = RT::Templates->new( RT->SystemUser );
358+
$templates->SelectAllColumns(1);
355359
$templates->LimitToGlobal;
356360

357361
$self->PushObj( $scrips, $templates );
@@ -360,6 +364,7 @@ sub PushBasics {
360364

361365
if ($self->{AllUsers}) {
362366
my $users = RT::Users->new( RT->SystemUser );
367+
$users->SelectAllColumns(1);
363368
$users->LimitToPrivileged;
364369
$self->PushObj( $users );
365370
}

lib/RT/ObjectContent.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ sub _CoreAccessible {
275275
id => { read => 1, type => 'int(19)', default => '' },
276276
ObjectType => { read => 1, write => 1, sql_type => 12, length => 64, is_blob => 0, is_numeric => 0, type => 'varchar(64)', default => '' },
277277
ObjectId => { read => 1, write => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => '' },
278-
Content => { read => 1, write => 1, sql_type => -4, length => 0, is_blob => 1, is_numeric => 0, type => 'longblob', default => '' },
278+
Content => { read => 1, write => 1, sql_type => -4, length => 0, is_blob => 1, is_numeric => 0, type => 'longblob', default => '', lazy_load => 1 },
279279
ContentEncoding => { read => 1, write => 1, sql_type => 12, length => 64, is_blob => 0, is_numeric => 0, type => 'varchar(64)', default => '' },
280280
Creator => { read => 1, type => 'int(11)', default => '0', auto => 1 },
281281
Created => { read => 1, type => 'datetime', default => '', auto => 1 },

lib/RT/ObjectCustomFieldValue.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ sub _CoreAccessible {
760760
Content =>
761761
{read => 1, write => 1, sql_type => 12, length => 255, is_blob => 0, is_numeric => 0, type => 'varchar(255)', default => ''},
762762
LargeContent =>
763-
{read => 1, write => 1, sql_type => -4, length => 0, is_blob => 1, is_numeric => 0, type => 'longblob', default => ''},
763+
{read => 1, write => 1, sql_type => -4, length => 0, is_blob => 1, is_numeric => 0, type => 'longblob', default => '', lazy_load => 1},
764764
ContentType =>
765765
{read => 1, write => 1, sql_type => 12, length => 80, is_blob => 0, is_numeric => 0, type => 'varchar(80)', default => ''},
766766
ContentEncoding =>

lib/RT/Record.pm

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2826,6 +2826,7 @@ sub CustomDateRanges {
28262826

28272827
if ( !$args{ExcludeUsers} ) {
28282828
my $attributes = RT::Attributes->new( RT->SystemUser );
2829+
$attributes->SelectAllColumns(1);
28292830
$attributes->Limit( FIELD => 'Name', VALUE => 'Pref-CustomDateRanges' );
28302831
$attributes->Limit( FIELD => 'ObjectType', VALUE => 'RT::User' );
28312832
if ( $args{ExcludeUser} ) {
@@ -2978,9 +2979,15 @@ sub Serialize {
29782979
%{ $args{Methods} || {} },
29792980
);
29802981

2982+
my %ca = %{ $self->_ClassAccessible };
2983+
2984+
# Fetch any lazy_load columns not yet in memory so they are included
2985+
for my $col ( grep { $ca{$_}{lazy_load} && !exists $self->{values}{lc $_} } keys %ca ) {
2986+
$self->_Value($col);
2987+
}
2988+
29812989
my %values = %{$self->{values}};
29822990

2983-
my %ca = %{ $self->_ClassAccessible };
29842991
my @cols = grep {exists $values{lc $_} and defined $values{lc $_}} keys %ca;
29852992

29862993
my %store;
@@ -3148,6 +3155,13 @@ sub _AsInsertQuery
31483155

31493156
my $table = $self->can('QuotedTableName') ? $self->QuotedTableName($self->Table) : $self->Table;
31503157
my $res = "INSERT INTO $table";
3158+
3159+
# Fetch any lazy_load columns not yet in memory so they are included
3160+
my %ca = %{ $self->_ClassAccessible };
3161+
for my $col ( grep { $ca{$_}{lazy_load} && !exists $self->{values}{lc $_} } keys %ca ) {
3162+
$self->_Value($col);
3163+
}
3164+
31513165
my $values = $self->{'values'};
31523166
$res .= "(". join( ",", map { $dbh->quote_identifier( $_ ) } sort keys %$values ) .")";
31533167
$res .= " VALUES";

lib/RT/Scrip.pm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,11 +1209,11 @@ sub _CoreAccessible {
12091209
ScripAction =>
12101210
{read => 1, write => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => '0'},
12111211
CustomIsApplicableCode =>
1212-
{read => 1, write => 1, sql_type => -4, length => 0, is_blob => 1, is_numeric => 0, type => 'text', default => ''},
1212+
{read => 1, write => 1, sql_type => -4, length => 0, is_blob => 1, is_numeric => 0, type => 'text', default => '', lazy_load => 1},
12131213
CustomPrepareCode =>
1214-
{read => 1, write => 1, sql_type => -4, length => 0, is_blob => 1, is_numeric => 0, type => 'text', default => ''},
1214+
{read => 1, write => 1, sql_type => -4, length => 0, is_blob => 1, is_numeric => 0, type => 'text', default => '', lazy_load => 1},
12151215
CustomCommitCode =>
1216-
{read => 1, write => 1, sql_type => -4, length => 0, is_blob => 1, is_numeric => 0, type => 'text', default => ''},
1216+
{read => 1, write => 1, sql_type => -4, length => 0, is_blob => 1, is_numeric => 0, type => 'text', default => '', lazy_load => 1},
12171217
Disabled =>
12181218
{read => 1, write => 1, sql_type => 5, length => 6, is_blob => 0, is_numeric => 1, type => 'smallint(6)', default => '0'},
12191219
Template =>

lib/RT/Shortener.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ sub _CoreAccessible {
323323
Code =>
324324
{read => 1, write => 1, sql_type => 12, length => 64, is_blob => 0, is_numeric => 0, type => 'varchar(40)', default => ''},
325325
Content =>
326-
{read => 1, write => 1, sql_type => -4, length => 0, is_blob => 1, is_numeric => 0, type => 'longtext', default => ''},
326+
{read => 1, write => 1, sql_type => -4, length => 0, is_blob => 1, is_numeric => 0, type => 'longtext', default => '', lazy_load => 1},
327327
Permanent =>
328328
{read => 1, write => 1, sql_type => 5, length => 6, is_blob => 0, is_numeric => 1, type => 'smallint(6)', default => '1'},
329329
Creator =>

lib/RT/Template.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,7 @@ sub _CoreAccessible {
12041204
Type =>
12051205
{read => 1, write => 1, sql_type => 12, length => 16, is_blob => 0, is_numeric => 0, type => 'varchar(16)', default => ''},
12061206
Content =>
1207-
{read => 1, write => 1, sql_type => -4, length => 0, is_blob => 1, is_numeric => 0, type => 'text', default => ''},
1207+
{read => 1, write => 1, sql_type => -4, length => 0, is_blob => 1, is_numeric => 0, type => 'text', default => '', lazy_load => 1},
12081208
LookupType =>
12091209
{read => 1, write => 1, sql_type => 12, length => 255, is_blob => 0, is_numeric => 0, type => 'varchar(255)', default => ''},
12101210
LastUpdated =>

lib/RT/Ticket.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3607,7 +3607,7 @@ sub _CoreAccessible {
36073607
Subject =>
36083608
{read => 1, write => 1, sql_type => 12, length => 200, is_blob => 0, is_numeric => 0, type => 'varchar(200)', default => '[no subject]'},
36093609
Description =>
3610-
{read => 1, write => 1, sql_type => -4, length => 0, is_blob => 1, is_numeric => 0, type => 'text', default => ''},
3610+
{read => 1, write => 1, sql_type => -4, length => 0, is_blob => 1, is_numeric => 0, type => 'text', default => '', lazy_load => 1},
36113611
InitialPriority =>
36123612
{read => 1, write => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => '0'},
36133613
FinalPriority =>

0 commit comments

Comments
 (0)