Re: [Dbix-class] prefetch specific columns
dreel
dreel at bk.ru
Wed Nov 28 13:07:44 GMT 2007
$c->stash->{routes} = $c->model('QDB::Routes')->search(
{
'me.net_id' => $c->stash->{net_id},
'me.route_beg' => $c->stash->{node_id_beg},
'me.route_end' => $c->stash->{node_id_end},
},
{
prefetch => { 'xc_params' => 'nodes' },
select => [
qw/
me.route_id me.route_beg me.route_end me.err_code me.comment me.net_id
xc_params.node_rank
xc_params.ch_beg xc_params.ch_end
xc_params.pt_beg xc_params.pt_end
xc_params.sh_beg xc_params.sh_end
xc_params.dr_beg xc_params.dr_end
nodes.node_id nodes.node_name nodes.node_type_id
/
],
as => [
qw/
route_id route_beg route_end err_code comment net_id
xc_params.node_rank
xc_params.ch_beg xc_params.ch_end
xc_params.pt_beg xc_params.pt_end
xc_params.sh_beg xc_params.sh_end
xc_params.dr_beg xc_params.dr_end
nodes.node_id nodes.node_name nodes.node_type_id
/
],
#TODO Постраничный вывод для спика маршрутов участка, переделать запрос с соединением разобрать вручную
order_by => $order_by,
page => $page, # page to return (defaults to 1)
rows => $rows, # number of results per page,
cache => 1
}
);
WHY DBIX PRODUCES THAT!! ...(
SELECT * FROM
(
SELECT TOP 5 * FROM
(
SELECT TOP 5 me.route_id, me.route_beg, me.route_end, me.err_code, me.comment, me.net_id, xc_params.node_rank, xc_params.ch_beg, xc_params.ch_end, xc_params.pt_beg, xc_params.pt_end, xc_params.sh_beg, xc_params.sh_end, xc_params.dr_beg, xc_params.dr_end, nodes.node_id, nodes.node_name, nodes.node_type_id,
############################# ADDED AUTOMATICALLY! Not me
xc_params.node_id, xc_params.route_id, xc_params.node_rank, xc_params.ch_beg, xc_params.ch_end, xc_params.pt_beg, xc_params.pt_end, xc_params.sh_beg, xc_params.sh_end, xc_params.dr_beg, xc_params.dr_end, xc_params.net_id, nodes.net_id, nodes.node_id, nodes.node_name, nodes.node_type_id
#############################
FROM vi_route me LEFT JOIN vi_xcparams xc_params ON ( xc_params.net_id = me.net_id AND xc_params.route_id = me.route_id ) LEFT JOIN vi_nodes nodes ON ( nodes.net_id = xc_params.net_id AND nodes.node_id = xc_params.node_id ) WHERE ( me.net_id = ? AND me.route_beg = ? AND me.route_end = ? ) ORDER BY route_beg ASC, xc_params.route_id ASC, xc_params.net_id ASC
) AS foo
ORDER BY route_beg DESC, xc_params.route_id DESC, xc_params.net_id DESC
) AS bar
ORDER BY route_beg ASC, xc_params.route_id ASC, xc_params.net_id ASC
prefetch mechanism IS NOT kicked in "... if you set up the select attr yourself with an as of 'relname.colname' ..."
Any suggestions?
paged output can't correctly working with prefetch it still uses full list of columns even I set 'select' 'as'
(((
--
dr.eel
More information about the DBIx-Class
mailing list