It's hard to debug your problem with only tiny snippets of the code.
Somewhere in your code or your template you are using the relationship
without the columns restriction or just by calling it via the relationship
method.
Can you reply including all the relevant bits of code, instead of just
tiny parts?
Or start debugging by using a very minimal app or script, and find out
yourself which piece of code is causing the SQL statements which fetch all
the columns.
DBIC does what you ask it, mostly..
Jess
On Mon, 2 Jan 2012, Miguel Barco wrote:
Thank you. All the pieces fit, despite I do not like the whole picture... And
it reveals an additional problem:
- The secondary, prefetched table, is always retrieving all the columns.
- I am using "columns => [@the_columns]" to select them, as is this excerpt:
-For easy queries to the main table I have:
@the_columns = qw / id name color /
- And I have added the needed columns from the secondary table
@ the_columns = qw / me.id me.name me.color
the_accessor.longdescription1 the_accessor.longresume1 /
The debug window shows the right SELECT in the first lines (from table 1 and
from table 2). But after that, it adds all the columns of the secondary
(longdescription2, longdescription3, etc). And they are big text fields and
blobs!!
It seems to be covered by the docs here but I do not fully understand the
"implicit" behavior that it talks about.
Regards:
Migue.
________________________________
De: Ben Tilly <[email protected]>
Para: Miguel Barco <[email protected]>; DBIx::Class user and developer list <[email protected]>
Enviado: lunes 2 de enero de 2012 18:24
Asunto: Re: [Dbix-class] I get only one in a one to one
You have stated all of the relevant facts, you just need to put it together.
When you prefetch, the SELECT adds a join to pull in the dependent
table in one fetch. When you don't prefetch, it remembers the
relationship, but only calls it at need. Therefore:
- When you prefetch, it hits database just once (but it is a heavier
hit to the database)
- If you remove prefetch, every row needs the relationship and it has
to SELECT each time to get it
- If you remove prefetch and the template, you don't need the
relationship, and there is no excess SELECTing.
On Mon, Jan 2, 2012 at 2:17 AM, Miguel Barco <[email protected]> wrote:
Wow!! It comes from the TT template!!!!
I have TT labels to print data form the secondary table [%
rsobject.relationship.column %]
- When I prefetch, it hits database just once and data goes to its place in
the template.
- If I remove prefetch, it makes a SELECT for all the rows, looking for the
relationship!!
- If I remove the prefetch and the TT label in the template, it ignores the
secondary.
So Template Toolkit is calling back the relationship, forcing queries to
fill all the labels ??????
I do not understand.
Migue.
_______________________________________________
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/[email protected]