5 pts.
 Querying against Views vs Tables
I have a view that combine several tables, so that the view presents more information that each table taken individually. I want to write an "INSERT INTO ... SELECT ... FROM xxx" query. Should I use the View in that "FROM xxx" or should I expand what the view shows? What's better in terms of optimization and/or business practice? (I run on MySQL if it makes any difference)

Software/Hardware used:
MySQL 5.1.52
ASKED: September 8, 2011  3:38 PM
UPDATED: March 31, 2012  4:58 PM
  Help
 Approved Answer - Chosen by Artaxerxes2 (Question Asker)

I would say that using the view or the underlying query would be the same in terms of performance, but if the business requirement is that the INSERT must always insert the same data than the one returned by the view, then you should use the view, so that if for any reason the view definition changes in the future, you don't have to remember to modify this insert as well.

On the contrary, if the INSERT is not directly related to the view, but the data you need to insert is coincidentally the same as the view (by now), then I would use the query.

ANSWERED:  Sep 8, 2011  4:19 PM (GMT)  by Artaxerxes2

 
Other Answers:
Last Wiki Answer Submitted:  July 1, 2012  2:59 pm  by    0 pts.
Latest Answer Wiki Contributors: 
To see other answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _