Re: [Dbix-class] Performance Issue

2012-02-21 Thread Alexander Hartmaier
So loading more modules takes longer than loading less modules, how does that 
surprise you?
The actual query takes almost the same time taking rounding errors into 
consideration.
How are you planning to use DBIC that startup and connection time is an issue 
for you?

Am 2012-02-20 23:04, schrieb Bill McCormick:
Bill McCormick wrote, On 2/20/2012 10:30 AM:
I just wrote a tiny little script, just using DBI and DBD::SQLite, and there is 
no delay.

#!/usr/bin/perl

use strict;

use DBI;
use DBD::SQLite;


my $recipes_sql = q/SELECT * FROM recipe/;

my $dbfile=/home/fiber/data/recipe.db3;

my $dbh = DBI-connect(dbi:SQLite:$dbfile) or croak $DBI::errstr;

my $recipe_ary_ref  = $dbh-selectall_arrayref($recipes_sql,{ Slice = {} });

foreach my $recipe ( @$recipe_ary_ref ) {
print qq/$recipe-{ID} $recipe-{NAME}\n/;
}


Thanks!!

Alexander Hartmaier wrote, On 2/20/2012 10:02 AM:

Are you sure you measure correctly?
Did you include Perl startup time by accident?

Am 2012-02-20 16:09, schrieb Bill McCormick:


I'm just getting started using DBIx::Class and I am a little surprised
at performance (rather, lack there of).

Perhaps I've missed some key point, index or other such thing, but it
takes well over a second to get results on a single table that has
very few records (20).

I am running on Debian Squeeze (Linux 2.6.33 i586) with perl (v5.10.1)
and SQLite3 (3.7.3).

If I export DBIC_TRACE=1 and then run the my script, I see this:

SELECT me.ID, me.NAME FROM recipe me:

So then if I run that query in sqlite3, it is markedly faster. I
understand that the DBIx::Class needs a little more time, this delay
makes me think I must have missed something.




I added some metrics. There is a HUGE (~1.5 sec) difference that needs to be 
accounted for here. Either I'm doing something very wrong (very likely) or 
there is something very wrong with DBIx.

Each test starts with this:
BEGIN {
print qq/* Start Test *\n/;
$start = clock();
print qq/Start: $start\n/;
}

The part that takes the longest is loading the DBIx::Schema compared to loading 
DBI  DBD, but even the DB connect an query takes longer.

use MyApp::Schema;

$tick = clock();
$ticktock = $tick - $start;
print qq/Load Use: $ticktock\n/;

compared to:
use DBI;
use DBD::SQLite;

$tick = clock();
$ticktock = $tick - $start;
print qq/Load Use: $ticktock\n/;

I appreciate any insight at all.

Thanks!!

Output here:
$:/home/fiber/www/cgi-bin# ./recipe-test-DBIx.pl;./recipe-test-DBI.pl
* Start Test *
Start: 0.08
Load Use: 1.12
Connect: 1.32
Query: 1.65
RECIPE 1
RECIPE 2
RECIPE 3
RECIPE 4
RECIPE 5
RECIPE 6
RECIPE 7
RECIPE 8
RECIPE 9
RECIPE 10
RECIPE 11
RECIPE 12
RECIPE 13
RECIPE 14
RECIPE 15
RECIPE 16
RECIPE 17
RECIPE 18
RECIPE 19
Complete: 1.66
* Start Test *
Start: 0.08
Load Use: 0.17
Connect: 0.18
Query: 0.19
1 RECIPE 1
2 RECIPE 2
3 RECIPE 3
4 RECIPE 4
5 RECIPE 5
6 RECIPE 6
7 RECIPE 7
8 RECIPE 8
9 RECIPE 9
10 RECIPE 10
11 RECIPE 11
12 RECIPE 12
13 RECIPE 13
14 RECIPE 14
15 RECIPE 15
16 RECIPE 16
17 RECIPE 17
18 RECIPE 18
19 RECIPE 19
Complete: 0.19





___
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk


***
T-Systems Austria GesmbH Rennweg 97-99, 1030 Wien
Handelsgericht Wien, FN 79340b
***
Notice: This e-mail contains information that is confidential and may be 
privileged.
If you are not the intended recipient, please notify the sender and then
delete this e-mail immediately.
***
___
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk

Re: [Dbix-class] Performance Issue

2012-02-21 Thread Bill McCormick
I'm not surprised that it takes more time. I am, however, surprised that 
it takes more than 0.5 sec. That fact that it takes more than 1.0 sec 
really has me scratching my head. I was hoping to run this with tt2 in a 
cgi web application on an a small system (running Squeeze) that's closer 
to an embedded device than a server class machine or even a desktop 
system. I'm using thttpd and SQLite as well, since they are lightweight 
and have small footprints.


Speed *is* an issue, however, I need to keep things as lightweight as 
possible. So the number of module dependencies is also an issue, 
especially if I won't be needing them.  So, for example, when I install 
DBIx::Class::Schema::Loader ... and it depends on some Lingua modules 
... which depend on some Text::German and Snowball::Swedish modules ... 
I think I'm looking at a lot of bloat. I only have a 2G flash drive to 
work with, and I need to save as much of that as possible for data storage.


If I cannot resolve these issues, then I don't think I should use 
DBIx::Class.


There really won't be more than a handful of web pages on this system, 
so using only Perl with the CGI module won't be so horrible.


Thanks!!

Alexander Hartmaier wrote, On 2/21/2012 2:49 AM:
So loading more modules takes longer than loading less modules, how 
does that surprise you?
The actual query takes almost the same time taking rounding errors 
into consideration.
How are you planning to use DBIC that startup and connection time is 
an issue for you?


Am 2012-02-20 23:04, schrieb Bill McCormick:

Bill McCormick wrote, On 2/20/2012 10:30 AM:
I just wrote a tiny little script, just using DBI and DBD::SQLite, 
and there is no delay.


#!/usr/bin/perl

use strict;

use DBI;
use DBD::SQLite;


my $recipes_sql = q/SELECT * FROM recipe/;

my $dbfile=/home/fiber/data/recipe.db3;

my $dbh = DBI-connect(dbi:SQLite:$dbfile) or croak $DBI::errstr;

my $recipe_ary_ref  = $dbh-selectall_arrayref($recipes_sql,{ Slice 
= {} });


foreach my $recipe ( @$recipe_ary_ref ) {
print qq/$recipe-{ID} $recipe-{NAME}\n/;
}


Thanks!!

Alexander Hartmaier wrote, On 2/20/2012 10:02 AM:

Are you sure you measure correctly?
Did you include Perl startup time by accident?

Am 2012-02-20 16:09, schrieb Bill McCormick:

I'm just getting started using DBIx::Class and I am a little surprised
at performance (rather, lack there of).

Perhaps I've missed some key point, index or other such thing, but it
takes well over a second to get results on a single table that has
very few records (20).

I am running on Debian Squeeze (Linux 2.6.33 i586) with perl (v5.10.1)
and SQLite3 (3.7.3).

If I export DBIC_TRACE=1 and then run the my script, I see this:

 SELECT me.ID, me.NAME FROM recipe me:

So then if I run that query in sqlite3, it is markedly faster. I
understand that the DBIx::Class needs a little more time, this delay
makes me think I must have missed something.


I added some metrics. There is a HUGE (~1.5 sec) difference that 
needs to be accounted for here. Either I'm doing something very wrong 
(very likely) or there is something very wrong with DBIx.


Each test starts with this:
BEGIN {
print qq/* Start Test *\n/;
$start = clock();
print qq/Start: $start\n/;
}

The part that takes the longest is loading the DBIx::Schema compared 
to loading DBI  DBD, but even the DB connect an query takes longer.


use MyApp::Schema;

$tick = clock();
$ticktock = $tick - $start;
print qq/Load Use: $ticktock\n/;

compared to:
use DBI;
use DBD::SQLite;

$tick = clock();
$ticktock = $tick - $start;
print qq/Load Use: $ticktock\n/;

I appreciate any insight at all.

Thanks!!

Output here:
$:/home/fiber/www/cgi-bin# ./recipe-test-DBIx.pl;./recipe-test-DBI.pl
* Start Test *
Start: 0.08
Load Use: 1.12
Connect: 1.32
Query: 1.65
RECIPE 1
RECIPE 2
RECIPE 3
RECIPE 4
RECIPE 5
RECIPE 6
RECIPE 7
RECIPE 8
RECIPE 9
RECIPE 10
RECIPE 11
RECIPE 12
RECIPE 13
RECIPE 14
RECIPE 15
RECIPE 16
RECIPE 17
RECIPE 18
RECIPE 19
Complete: 1.66
* Start Test *
Start: 0.08
Load Use: 0.17
Connect: 0.18
Query: 0.19
1 RECIPE 1
2 RECIPE 2
3 RECIPE 3
4 RECIPE 4
5 RECIPE 5
6 RECIPE 6
7 RECIPE 7
8 RECIPE 8
9 RECIPE 9
10 RECIPE 10
11 RECIPE 11
12 RECIPE 12
13 RECIPE 13
14 RECIPE 14
15 RECIPE 15
16 RECIPE 16
17 RECIPE 17
18 RECIPE 18
19 RECIPE 19
Complete: 0.19




___
List:http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN:http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive:http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk



***
T-Systems Austria GesmbH Rennweg 97-99, 1030 Wien
Handelsgericht Wien, FN 79340b
***
Notice: This e-mail contains information that is confidential and may 
be privileged.

If you are not the intended recipient, please notify the sender and then
delete this e-mail immediately.

Re: [Dbix-class] Performance Issue

2012-02-21 Thread Peter Rabbitson
On Mon, Feb 20, 2012 at 04:04:13PM -0600, Bill McCormick wrote:
 I added some metrics. There is a HUGE (~1.5 sec) difference that needs  
 to be accounted for here. Either I'm doing something very wrong (very  
 likely) or there is something very wrong with DBIx.

 Each test starts with this:
 BEGIN {
 print qq/* Start Test *\n/;
 $start = clock();
 print qq/Start: $start\n/;
 }

 The part that takes the longest is loading the DBIx::Schema compared to  
 loading DBI  DBD, but even the DB connect an query takes longer.

snip


 $:/home/fiber/www/cgi-bin# ./recipe-test-DBIx.pl;./recipe-test-DBI.pl
 * Start Test *
 Start: 0.08
^^ ok

 Load Use: 1.12
^^ this depending on the size of your schema may be normal or may not be

 Connect: 1.32
 Query: 1.65
 Complete: 1.66
^^ diagnosing the rest without your actual schema is impossible

See my next email

___
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk


Re: [Dbix-class] Performance Issue

2012-02-21 Thread Bill McCormick

Peter Rabbitson wrote, On 2/21/2012 9:05 AM:

On Tue, Feb 21, 2012 at 08:49:31AM -0600, Bill McCormick wrote:

I'm not surprised that it takes more time. I am, however, surprised that
it takes more than 0.5 sec.

Near-second loadtimes are *nothing* unusual in today's perl ecosystem. I
do not like this fact myself, and try to keep DBIC as lean as possible, so
I am *very* interested in your cooperation to enumerate the hotspots in
your case and possibly even fix oversights in DBIx::Class.


That fact that it takes more than 1.0 sec
really has me scratching my head. I was hoping to run this with tt2 in a
cgi web application on an a small system (running Squeeze) that's closer
to an embedded device than a server class machine or even a desktop
system. I'm using thttpd and SQLite as well, since they are lightweight
and have small footprints.

DBIC does a lot of stuff to optimize for long-running, large-dataset apps.
While we probably can take care of the startup costs, keep in mind that
we deliberately trade memory for speed where possible, so if your embedded
environment has limited memory amounts - you will need to profile this
aspect as well.
Is there something that can be done to minimize load time on post? I 
suppose there would need to be some way to make something persistent.

Speed *is* an issue, however, I need to keep things as lightweight as
possible. So the number of module dependencies is also an issue,
especially if I won't be needing them.  So, for example, when I install
DBIx::Class::Schema::Loader ... and it depends on some Lingua modules
... which depend on some Text::German and Snowball::Swedish modules ...
I think I'm looking at a lot of bloat.

You are looking at English (the language) being bloated and hard to work
with. Schema::Loader *must* be able to singularize/pluralize table names
which it does with a ton of natural language processing tools. However
this is irrelevant to your case, as DBIx::Class::Schema::Loader is not
(and never has been) a dependency of DBIx::Class, so I am not sure what
is the exact complaint here...
OK. I think I installed DBIx::Class::Schema::Loader in an late night 
effort to get to the bottom of what was happening, without really 
understanding it's use.

I only have a 2G flash drive to
work with, and I need to save as much of that as possible for data
storage.

An average distribution is about 1m unpacked, I doubt the amount of modules
used (even without you cleaning up your clearly bloated dep-tree) will not
even make a dent in the 2G available.

OK, that's good.

If I cannot resolve these issues, then I don't think I should use
DBIx::Class.

If you are serious about getting these issues diagnosed - please dump your
MyApp::Schema (and all result classes) somewhere public, and also generate
and provide a full profile of the test script run. Something like:

NYTPROF=clock=2 perl -d:NYTProf -Iinclist  ./recipe-test-DBIx.pl
nytprofhtml -lsame inclist like above, important

The resulting nytprof directory will contain both your source and a very
detailed profile of all slowdowns and tight places. Looking forward to
these datapoints, so we can help you further.

I don't seem to have nytprof. Looking on cpan, there are quite a few 
offerings. Could you recommend one? Also, can you recommend somewhere 
public to dump MyApp::Schema?


Thanks!!

___
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk


Re: [Dbix-class] Performance Issue

2012-02-21 Thread Peter Rabbitson
On Tue, Feb 21, 2012 at 09:31:31AM -0600, Bill McCormick wrote:

 I don't seem to have nytprof. Looking on cpan, there are quite a few  
 offerings. Could you recommend one? Also, can you recommend somewhere  
 public to dump MyApp::Schema?

Sorry I meant Devel::NYTProf. This is the only perl profiler worth using.
As far as where to dump the schema - github is free and many seem to have
experience with it. Or just use some pastebin site or something.

___
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk


[Dbix-class] Updating many-to-many relationships

2012-02-21 Thread David Cantrell
I have a bunch of classes set up as part of the ACL system for this 'ere
application what I'm writing.  There is a 'user' table, a 'role' table,
and sitting in between them a 'user_role' table.  Users can have any
arbitrary combination of roles, so this is yer classic many-to-many
situation. Pared down to the minimum, the classes are:

  package Database::Result::User;
  use base 'DBIx::Class::Core';
  __PACKAGE__-table('user');
  __PACKAGE__-add_columns(
id   = { data_type = 'INT',  is_nullable = 0 }, # autoinc
status   = { data_type = 'CHAR', is_nullable = 0 },
username = { data_type = 'CHAR', is_nullable = 0 }
  );
  __PACKAGE__-set_primary_key( id );
  __PACKAGE__-has_many( user_roles, Database::Result::UserRole, { 
'foreign.user_id' = self.id } );
  1;

  package Database::Result::UserRole;
  use base 'DBIx::Class::Core';
  __PACKAGE__-table('user_role');
  __PACKAGE__-add_columns(
user_id = { data_type = 'INT', is_nullable = 0 },
role_id = { data_type = 'INT', is_nullable = 0 },
  );
  __PACKAGE__-set_primary_key( qw(user_id role_id) );
  __PACKAGE__-belongs_to(user, Database::Result::User, { 'foreign.id' = 
'self.user_id' });
  __PACKAGE__-belongs_to(role, Database::Result::Role, { 'foreign.id' = 
'self.role_id' });
  1;

  package Database::Result::Role;
  use base 'DBIx::Class::Core';
  __PACKAGE__-table('role');
  __PACKAGE__-add_columns(
id   = { data_type = 'INT',  is_nullable = 0 }, # autoinc
name = { data_type = 'CHAR', is_nullable = 0 },
  );
  __PACKAGE__-set_primary_key( id );
  __PACKAGE__-has_many( user_roles, Database::Result::UserRole, { 
'foreign.role_id' = self.id } );
  1;

I can create users with roles easily, creating roles on the fly if
necessary:

  my $person = ...-create({
username   = 'anselm',
status = 'alive',
user_roles = [
  { role = { name = 'Monk' } },
  { role = { name = 'Archbishop' } },
]
  });

I couldn't see this documented anywhere, but found it in the mailing
list archives.  It creates any necessary entries in the 'role' table,
and in the 'user_role' table.

However, I can't find any nice way of updating a user's
roles, something like this (which I tried, but it doesn't work) ...

  $person-status('dead');
  $person-user_roles([
{ role = { name = 'Saint' } }
  ]);
  $person-update();

Am I missing something?  It would make my life ever so pleasant if there
were a nice easy way of doing this.  As it is, however, the call to the
user_roles() method is not having any effect at all - there's no queries
generated whatsoever for it, just the UPDATE to change the status from
alive to dead.

-- 
David Cantrell | even more awesome than a panda-fur coat

There is no one true indentation style,
But if there were KR would be Its Prophets.
Peace be upon Their Holy Beards.

___
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk


Re: [Dbix-class] Performance Issue

2012-02-21 Thread Bill McCormick

Peter Rabbitson wrote, On 2/21/2012 9:05 AM:

On Tue, Feb 21, 2012 at 08:49:31AM -0600, Bill McCormick wrote:

I'm not surprised that it takes more time. I am, however, surprised that
it takes more than 0.5 sec.

Near-second loadtimes are *nothing* unusual in today's perl ecosystem. I
do not like this fact myself, and try to keep DBIC as lean as possible, so
I am *very* interested in your cooperation to enumerate the hotspots in
your case and possibly even fix oversights in DBIx::Class.


That fact that it takes more than 1.0 sec
really has me scratching my head. I was hoping to run this with tt2 in a
cgi web application on an a small system (running Squeeze) that's closer
to an embedded device than a server class machine or even a desktop
system. I'm using thttpd and SQLite as well, since they are lightweight
and have small footprints.

DBIC does a lot of stuff to optimize for long-running, large-dataset apps.
While we probably can take care of the startup costs, keep in mind that
we deliberately trade memory for speed where possible, so if your embedded
environment has limited memory amounts - you will need to profile this
aspect as well.


Speed *is* an issue, however, I need to keep things as lightweight as
possible. So the number of module dependencies is also an issue,
especially if I won't be needing them.  So, for example, when I install
DBIx::Class::Schema::Loader ... and it depends on some Lingua modules
... which depend on some Text::German and Snowball::Swedish modules ...
I think I'm looking at a lot of bloat.

You are looking at English (the language) being bloated and hard to work
with. Schema::Loader *must* be able to singularize/pluralize table names
which it does with a ton of natural language processing tools. However
this is irrelevant to your case, as DBIx::Class::Schema::Loader is not
(and never has been) a dependency of DBIx::Class, so I am not sure what
is the exact complaint here...


I only have a 2G flash drive to
work with, and I need to save as much of that as possible for data
storage.

An average distribution is about 1m unpacked, I doubt the amount of modules
used (even without you cleaning up your clearly bloated dep-tree) will not
even make a dent in the 2G available.



If I cannot resolve these issues, then I don't think I should use
DBIx::Class.

If you are serious about getting these issues diagnosed - please dump your
MyApp::Schema (and all result classes) somewhere public, and also generate
and provide a full profile of the test script run. Something like:

NYTPROF=clock=2 perl -d:NYTProf -Iinclist  ./recipe-test-DBIx.pl
nytprofhtml -lsame inclist like above, important

The resulting nytprof directory will contain both your source and a very
detailed profile of all slowdowns and tight places. Looking forward to
these datapoints, so we can help you further.


Can I assume that NYTPROF=clock=2 is an environment var setting? So then ...

$export NYTPROF=clock=2; perl -d:NYTProf -Iinclist ./recipe-test-DBIx.pl

Also, inclist is the dir of MyApp Schema.pm?


___
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk


Re: [Dbix-class] Updating many-to-many relationships

2012-02-21 Thread Alexander Hartmaier
You can find an example in the many_to_many relationship bridge docs:
https://metacpan.org/module/DBIx::Class::Relationship#many_to_many

Am 2012-02-21 17:11, schrieb David Cantrell:
 I have a bunch of classes set up as part of the ACL system for this 'ere
 application what I'm writing.  There is a 'user' table, a 'role' table,
 and sitting in between them a 'user_role' table.  Users can have any
 arbitrary combination of roles, so this is yer classic many-to-many
 situation. Pared down to the minimum, the classes are:

   package Database::Result::User;
   use base 'DBIx::Class::Core';
   __PACKAGE__-table('user');
   __PACKAGE__-add_columns(
 id   = { data_type = 'INT',  is_nullable = 0 }, # autoinc
 status   = { data_type = 'CHAR', is_nullable = 0 },
 username = { data_type = 'CHAR', is_nullable = 0 }
   );
   __PACKAGE__-set_primary_key( id );
   __PACKAGE__-has_many( user_roles, Database::Result::UserRole, { 
 'foreign.user_id' = self.id } );
   1;

   package Database::Result::UserRole;
   use base 'DBIx::Class::Core';
   __PACKAGE__-table('user_role');
   __PACKAGE__-add_columns(
 user_id = { data_type = 'INT', is_nullable = 0 },
 role_id = { data_type = 'INT', is_nullable = 0 },
   );
   __PACKAGE__-set_primary_key( qw(user_id role_id) );
   __PACKAGE__-belongs_to(user, Database::Result::User, { 'foreign.id' = 
 'self.user_id' });
   __PACKAGE__-belongs_to(role, Database::Result::Role, { 'foreign.id' = 
 'self.role_id' });
   1;

   package Database::Result::Role;
   use base 'DBIx::Class::Core';
   __PACKAGE__-table('role');
   __PACKAGE__-add_columns(
 id   = { data_type = 'INT',  is_nullable = 0 }, # autoinc
 name = { data_type = 'CHAR', is_nullable = 0 },
   );
   __PACKAGE__-set_primary_key( id );
   __PACKAGE__-has_many( user_roles, Database::Result::UserRole, { 
 'foreign.role_id' = self.id } );
   1;

 I can create users with roles easily, creating roles on the fly if
 necessary:

   my $person = ...-create({
 username   = 'anselm',
 status = 'alive',
 user_roles = [
   { role = { name = 'Monk' } },
   { role = { name = 'Archbishop' } },
 ]
   });

 I couldn't see this documented anywhere, but found it in the mailing
 list archives.  It creates any necessary entries in the 'role' table,
 and in the 'user_role' table.

 However, I can't find any nice way of updating a user's
 roles, something like this (which I tried, but it doesn't work) ...

   $person-status('dead');
   $person-user_roles([
 { role = { name = 'Saint' } }
   ]);
   $person-update();

 Am I missing something?  It would make my life ever so pleasant if there
 were a nice easy way of doing this.  As it is, however, the call to the
 user_roles() method is not having any effect at all - there's no queries
 generated whatsoever for it, just the UPDATE to change the status from
 alive to dead.



***
T-Systems Austria GesmbH Rennweg 97-99, 1030 Wien
Handelsgericht Wien, FN 79340b
***
Notice: This e-mail contains information that is confidential and may be 
privileged.
If you are not the intended recipient, please notify the sender and then
delete this e-mail immediately.
***

___
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk


Re: [Dbix-class] Performance Issue

2012-02-21 Thread Bill McCormick

Peter Rabbitson wrote, On 2/21/2012 9:36 AM:

On Tue, Feb 21, 2012 at 09:31:31AM -0600, Bill McCormick wrote:

I don't seem to have nytprof. Looking on cpan, there are quite a few
offerings. Could you recommend one? Also, can you recommend somewhere
public to dump MyApp::Schema?

Sorry I meant Devel::NYTProf. This is the only perl profiler worth using.
As far as where to dump the schema - github is free and many seem to have
experience with it. Or just use some pastebin site or something.

I already had github account, but I had not yet used it until now. I 
just spent the whole morning trying to figure it out. What a chore. 
Getting some sort of revision control up and running was on my 
list-of-things-to-do, and I was pushing for subversion, but now I have 
Git, so maybe I should just figure it out.


I created a wpmccormick/recipe repository that I think you should be 
able to get to.


I guess I'll move forward with DBIC in hopes that you can help me figure 
out how to make it faster. If not, I suppose I'll be able use whatever 
templates I create with straight perl/cgi.


Thanks,

Bill

___
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk


Re: [Dbix-class] Updating many-to-many relationships

2012-02-21 Thread David Cantrell
On Tue, Feb 21, 2012 at 06:24:03PM +0100, Alexander Hartmaier wrote:

 You can find an example in the many_to_many relationship bridge docs:
 https://metacpan.org/module/DBIx::Class::Relationship#many_to_many

Nothing helpful there I'm afraid, just an Exciting Bug (or maybe just a
not so exciting lack of documentation).

If I add this:

__PACKAGE__-many_to_many(user_roles_many_to_many = 'user_roles', 'role');

Then if I have a user who already has role 'Philosophise' and do this:

...-set_user_roles_many_to_many(
  [
{ role = { name = 'Philosophise' } }
  ]
);

Then it deletes all that user's records from the user_roles table (which
is, I presume, the correct behaviour before re-populating it), but then
generates this broken SQL:

SELECT role.id, role.name FROM role role WHERE ( role.role NAME 'Philosophise' )

Maybe I'm calling it wrong, but it's not at all obvious what I should be
doing as I can't see any documentation for the set_$method apart from
that it exists - I ASSumed that the data should look the same as when I'm
doing an INSERT!

-- 
David Cantrell | Reality Engineer, Ministry of Information

Deck of Cards: $1.29.
101 Solitaire Variations book: $6.59.
Cheap replacement for the one thing Windows is good at: priceless
-- Shane Lazarus

___
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk