[Dbix-class] Loading ResultSource's abit like a trait
Jeffrey Fuller
jfuller at mvpbanking.com
Tue Nov 9 15:41:57 GMT 2010
> Hello all,
>
> I have a dbix::class schema with quite a few resultsource files.
>
> The schema is used by a few different apps.
>
> Typically only a few a of the resultsource files need to be loaded as
> the app using the schema is only touching a few tables.. but in other
> applications alot more of the resultsource files are needed.
>
> The start up time and mem foot print is alot larger than it could be
> for the apps only using part of the schema .. so ...
>
> My question is, is there is a way to instanciate a schema but only
> loading a few of the resultsource files?
>
> I was thinking perhaps I could do something that loads resultsource
> files simlar to traits but am not sure if this is advisable or if
> there is already something that does this?
>
> Many thanks for any comments/advise/links you have that might help.
>
> Cheers,
> -Ben
Basically what I do is just create a schema class on a per app basis
that only pulls in the classes we're using for it. An example would look
something like:
package <Company>::App::<AppName>::Schema;
use strict; use warnings;
use parent 'DBIx::Class:Schema';
__PACKAGE__->load_classes({
'<Company>::DBIC::<Db>::Schema::Result' => [qw(User Post Category)],
});
More information about the DBIx-Class
mailing list