For example, I have a page to display one product. A sql select for this product is executed.
But I also need to know how many products in this group, and in the order of the name, which product is the previous product which is the next product of the current product. So a sql to select all the products in this group is needed.
Instead of doing two sqls. I just one sql, select all the products in this group.
And save all the products information in arraies. And then display the product I want to display by calling the elment of the arraies.
Which is performacing better?
1) sql for the product to get the display information, and sql for the group to get the group count, and product id for the previous product and next product?
2) or one sql get all the products and save all the information in arraies. But pick up the index to display certain product (element of the arraies)?
Second approach saved on sql but use arraies to save a lot of information which is not used. Is this a bad practice?