[Dbix-class] Naming columns in nested joins

Brandon Black blblack at gmail.com
Wed May 24 16:46:19 CEST 2006


On 5/24/06, Matt S Trout <dbix-class at trout.me.uk> wrote:
> The DBIC search syntax is effectively an SQL abstract syntax tree; if
> you want to maintain total abstraction for client applications, adding
> (and documenting :) a custom resultset class with additional search
> methods that hide these implementation details is the way forwards.
>

I was thinking more about what you said the other day, re: creating
views for all complex queries, and I think that bears on this as well.
 Perhaps anytime one finds oneself making a very complex query in raw
SQL or as a hugely convoluted ->search(), it is best to go back to the
DB level and CREATE VIEW with that query, and just have the view be
another simple DBIC source that one can run simple queries on.  Or at
the very least, it's something to strongly consider in each such case.

With some vendors/situations/queries, this may of course be suboptimal
for performance, but it's cleaner, and in some cases probably actually
faster (as I would imagine at least some of the vendors
pre-parse/prepare/plan the select that makes up the view on the server
side permanently).

-- Brandon



More information about the Dbix-class mailing list