If in the "sections" section you mean separate separate pages (separate HTTP requests) that users can browse, I would suggest a type request as necessary. If on a page where there are only image data sets, you really don't need to take a video data set, for example. You wonโt be able to save a lot of time fetching everything, since you still connect to the database for each page screen (suppose.)
If in the "sections" section you mean different parts of one page, then take it all at once. This will save you time on a request (only one request.)
But, depending on the size of your dataset, you may run into problems with the request to limit the amount of PHP memory for everything. Then you can try to increase the memory limit, but if that fails, you will probably have to return to the query for the type.
Using the query-per-type approach transfers part of the computational load to the database server, since you will request and receive what you really need. And you do not need to write code to filter and sort the results. Filtering and sorting is that the database is generally better than the PHP code. If at all possible, turn on the MySQL query cache, which will speed up these queries much more than anything you could write in PHP.
fresch
source share