Every bit of literature I've found on this topic suggests that the advantage of using views lies in how much cleaner it makes the code. What I'd like to know is if I fire multiple selects one after the other, will the latency (Apache to MySQL to Apache multiple times) be significantly higher than using a complicated view. I have a scenario where I can take one of two approaches:
- Use individual queries. As I understand it, this is what MySQL does anyway even when I use views. But will there be a latency issue since I will be executing one query, parsing it on the PHP backend to get the filters for the next query and then sending that query over to the MySQL server (and so on, say, anywhere between 1 to 4 times, i.e., I will be running 2 to 5 queries in total)? In other words, Query1->PHP->Query2->PHP->...
- Build complex views. Since it's likely I will have elements in one table with no corresponding entry in the other, the final view is likely to have multiple UNIONS or JOINS even if it is being created out of two tables. But since there is no question of latency here and all the processing and filtering is done at the MySQL server side, will there be an improvement in performance?
What would help me deliver pages faster to my users?
Any help based on actual observation or proven documentation will be welcome.
Thanks.
SR