[Dbix-class] memory usage to load schema

Bernhard Graf dbic4 at augensalat.de
Wed Feb 3 14:55:54 GMT 2010


Rob Kinyon schrieb:

> On Wed, Jan 27, 2010 at 00:29, Julien Sobrier <julien at sobrier.net> wrote:
>> Hello,
>> I have an application that uses DBIx::Class:Schema to load 28 tables with
>> relationships between all of them. It takes 14 MB up front just to load all
>> these tables. I got this number by using GTop and checking the increase of
>> proc_mem->rss after loading the Schema class.
>>
>> That seem to be a load of memory for just loading the libraries. Does it
>> seem excessive in your experience? Is there any way to reduce the memory
>> usage?
> 
> This is not excessive in the slightest. Try this: create a duplicate
> of each table Foo called FooCopy. So, you have 56 tables. Now, see how
> much memory is used. I'll bet it's around 16MB.

How comes?

And how much can we rely on what (g)top or any other system monitor
tells us about memory usage?

When I define my DBIC result classes, then I very often use the same
column definition.

Would I save something (besides typing and disk space), if I'd write:

  package DBIC::Type;
  use constant {
    varchar_255 => {
      data_type => 'varchar',
      is_nullable => 1,
      size => '255',
    },
    ... more common column definitions here ...
  };

  package MyApp::Schema::Result::SomeTable;
  use DBIC::Type;
  ...
  __PACKAGE__->add_columns(
    ...
    firstname => DBIC::Type::varchar_255,
    lastname => DBIC::Type::varchar_255,
    address => DBIC::Type::varchar_255,
    ...
  );

?

Looks even DRYer, btw.


Bernhard Graf



More information about the DBIx-Class mailing list