title: MySQL: Views vs Stored Procedures
body: <p>Since MySQL started supporting stored procedures, I've never really used them.  Partly because I'm not a great query writer, partly because I often work with DBAs who make those choices for me, partly because I'm just comfy with What I Know.</p>
  
  <p>In terms of doing data selection, specifically when considering a select that is essentially a de-normalization (joins) and aggregate (avg or max, subqueries w/counts, etc) selection of data, what is the right choice in MySQL 5.x?  A view?  Or a stored procedure?</p>
  
  <p>Views I'm comfortable with - you know what your SELECT query is supposed to look like so you just create that, make sure it indexed and whatnot, then just do a <code>CREATE VIEW [View] AS SELECT [...]</code>.  Then, in my application, I treat the view as a read-only table - it represents a de-normalized version of my normalized data.</p>
  
  <p>What are the disadvantages here - if any?  And what would change (gains or losses) if I moved that exact same SELECT statement into a stored procedure?</p>
  
  <p>I'm hoping to find some good 'under the hood' info that has been difficult to find while googling this topic but really I welcome all comments and answers.</p>