Friday, 15 March 2013

php - Most optimized query to render a grid of items that have 1:n relationships, is using group_concat? -



php - Most optimized query to render a grid of items that have 1:n relationships, is using group_concat? -

it seems me using group_concat() performs best when querying info render list view, require several separate queries, when not using group_concat() (with big tables). true in case?

and there other downsides, besides having group_concat_max_len big enough?

it quite easy utilize when allow mysql dirty work; generates valid json (generated sql):

<<<sql select concat( '[{', group_concat( concat( '"id":"', table.id, '"' "," '"filename":"', replace('"', '\"', table.filenamehash), '"' "," '"originalname":"', replace('"', '\"', table.originalname), '"' ) separator '},{' ), '}]' ) file_data sql;

php mysql json relationship group-concat

No comments:

Post a Comment