php - JOINS vs. Group_Concat() - multiple one to many relationships -
i have table posts has 1 many relationship multiple tables (files , categories in simplified example below). posts has many fields returns each row.
if returning 1000 rows of posts , have 4 files , 3 categories per post, 12000 records in result set (duplicating post info in order give me file info). grows , grows each 1 many relationship.
below shows on simplified version of current join , contemplated group_concat() version. group_concat method simplify php handling tremendously.
comments on performance of these 2 methods?
update realize main concern join method not php code, server memory (& cpu resources?) consumed processing larger result set. each row can have significant amount of data since have type text field.
using joins
select p.postid, title, fileid, filename, category posts p left join files f on f.postid = p.postid left join categories c on c.postid = p.postid using group_concat()
select p.postid, title, ( select group_concat( concat_ws(",", fileid, filename) separator ';') files f f.postid = p.postid ) fileinfo select group_concat(category) categories cat.postid = p.postid ) catinfo posts p
Comments
Post a Comment