<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><title></title>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
body {
margin: 5px 5px 5px 5px;
background-color: #ffffff;
}
/* ========== Text Styles ========== */
hr { color: #000000}
body, table /* Normal text */
{
font-size: 9pt;
font-family: 'Courier New';
font-style: normal;
font-weight: normal;
color: #000000;
text-decoration: none;
}
span.rvts1 /* Heading */
{
font-size: 10pt;
font-family: 'Arial';
font-weight: bold;
color: #0000ff;
}
span.rvts2 /* Subheading */
{
font-size: 10pt;
font-family: 'Arial';
font-weight: bold;
color: #000080;
}
span.rvts3 /* Keywords */
{
font-size: 10pt;
font-family: 'Arial';
font-style: italic;
color: #800000;
}
a.rvts4, span.rvts4 /* Jump 1 */
{
font-size: 10pt;
font-family: 'Arial';
color: #008000;
text-decoration: underline;
}
a.rvts5, span.rvts5 /* Jump 2 */
{
font-size: 10pt;
font-family: 'Arial';
color: #008000;
text-decoration: underline;
}
span.rvts6
{
font-size: 11pt;
font-family: 'tahoma';
font-weight: bold;
color: #ffffff;
background-color: #0000ff;
}
span.rvts7
{
font-size: 11pt;
font-family: 'tahoma';
}
span.rvts8
{
font-size: 11pt;
}
span.rvts9
{
font-size: 8pt;
font-family: 'arial';
font-style: italic;
color: #c0c0c0;
}
a.rvts10, span.rvts10
{
font-size: 8pt;
font-family: 'arial';
color: #0000ff;
text-decoration: underline;
}
/* ========== Para Styles ========== */
p,ul,ol /* Paragraph Style */
{
text-align: left;
text-indent: 0px;
padding: 0px 0px 0px 0px;
margin: 0px 0px 0px 0px;
}
.rvps1 /* Centered */
{
text-align: center;
}
--></style>
</head>
<body>
<p>Здравствуйте, Angel.</p>
<p><br></p>
<p>Вы писали 8 декабря 2007 г., 18:36:55:</p>
<p><br></p>
<div><table border=0 cellpadding=1 cellspacing=2>
<tr valign=top>
<td width=12 style="background-color: #0000ff;">
<p><span class=rvts6>></span></p>
</td>
<td width=857 style="background-color: #ffffff;">
<p><span class=rvts7>Hi, All. Im new in DBIx::Class and this is my first question here :)</span></p>
<p><span class=rvts7>I write catalyst app and use dbic for 3 tables (males,females,family) with has_many and may_to_many. All works, but there are too many requests to my database when i use this: </span></p>
<p><span class=rvts8> my $rs = $c->model('AppModelDB::ClientMale')->search();</span></p>
<p><span class=rvts8>while (my $line = $rs->next) {</span></p>
<p><span class=rvts8> push @{$families},[ $line->client_family->first->id,</span></p>
<p><span class=rvts8> make_family(</span></p>
<p><span class=rvts8> $line->first_n, </span></p>
<p><span class=rvts8> $line->family_n,</span></p>
<p><span class=rvts8> $line->client_female->first->first_n,</span></p>
<p><span class=rvts8> $line->client_female->first->family_n </span></p>
<p><span class=rvts8> )</span></p>
<p><span class=rvts8> ,$line->client_family->first->city</span></p>
<p><span class=rvts8> ,$line->client_family->first->zip_code</span></p>
<p><span class=rvts8> ,$line->client_family->first->municipality </span></p>
<p><span class=rvts8> ,$line->client_family->first->street</span></p>
<p><span class=rvts8> ,$line->client_family->first->public_place_type</span></p>
<p><span class=rvts8> ,$line->client_family->first->public_place_name</span></p>
<p><span class=rvts8> ];</span></p>
<p><span class=rvts8> }</span></p>
<p><span class=rvts8>}</span></p>
<p><span class=rvts8>$c->stash->{families} = $families;</span></p>
<p><br></p>
<p><span class=rvts7>I wrote "export DBIC_TRACE=1" for debug and saw alot of screens with SELECT requests to MySQL. Plese help me to optimize the code. Every single table has around 190 lines. </span></p>
<p><span class=rvts7>Thank you</span></p>
</td>
</tr>
</table>
</div>
<p><br></p>
<p><br></p>
<p>Use 'join' or 'prefetch' attribute for search. Also see the Cookbook http://search.cpan.org/~ash/DBIx-Class-0.08008/lib/DBIx/Class/Manual/Cookbook.pod#JOINS_AND_PREFETCHING</p>
<p><br></p>
<p><span class=rvts9>-- </span></p>
<p><span class=rvts9>С уважением,</span></p>
<p><span class=rvts9> dreel </span><a class=rvts10 href="mailto:dreel@bk.ru">mailto:dreel@bk.ru</a></p>
</body></html>