in reply to Re: Inserting a relation into a database with Class::DBI
in thread Inserting a relation into a database with Class::DBI

Though I appreciate the response, this doesn't really address my primary question.

Namely, I only want a single insert taking place in this code (instead of one insert each for $session_rec and $user_rec). Since there's no need to touch the database twice, it feels dirty to me to issue two queries for an action that could be done in parallel.

Is there a way to compress the inserts into a single call (or at least a single database access)? Since $session_rec has a has_a() relationship with $user_rec, I don't see why DBI::Class wouldn't be smart enough to handle this.

  • Comment on Re^2: Inserting a relation into a database with Class::DBI

Replies are listed 'Best First'.
Re^3: Inserting a relation into a database with Class::DBI
by agianni (Hermit) on May 29, 2007 at 17:54 UTC
    I don't know of any easy way to do what you want in one query in C::DBI. Generally, if you are concerned about performance, particularly the number of queries being executed, you should probably be looking at an alternative to C::DBI, as it regularly executes lots of queries where a smaller number would suffice. I don't have any specific recommendations for alternatives, but I know there are a few others out there.
    perl -e 'split//,q{john hurl, pest caretaker}and(map{print @_[$_]}(joi +n(q{},map{sprintf(qq{%010u},$_)}(2**2*307*4993,5*101*641*5261,7*59*79 +*36997,13*17*71*45131,3**2*67*89*167*181))=~/\d{2}/g));'