title: Indexed Views in OLTPs?
body: <p>I'm familiar with SQL Server Indexed Views (or Oracle Materialized Views), we use them in our OLAP applications. They have the really cool feature of being able to usurp an execution plan and remap it to the indexed view w/out having to change existing code.</p>
  
  <p>IE. Let's say I had a SPROC that was a really expensive join.</p>
  
  <blockquote>
    <p>SELECT [SOME COLUMNS]<br>
    FROM Table1 INNER JOIN Table2 [DETAILS]<br>
    INNER JOIN Table3 [BUNCH MORE JOINS]
    ...</p>
  </blockquote>
  
  <p>If I authored an indexed view that held a similar result set then the Query Optimizer will very likely send the SPROC to my indexed view as opposed to the base tables and I get a big performance increase.</p>
  
  <p>Now say I wanted to use indexed views in an <strong>OLTP!?</strong> I mean most OLTPs (like this site) are relatively read heavy, if they have expensive joins then we could speed them up a ton AND potentially reduce locking contention (<a href="http://www.codinghorror.com/blog/archives/001166.html" rel="nofollow noreferrer">http://www.codinghorror.com/blog/archives/001166.html</a>). Even better is you wouldn't have to change any code, just author the indexed view.</p>
  
  <p>But this also means the database gets bigger since we need to keep a copy of these data in the indexed view...</p>
  
  <p><strong>Has anyone ever used indexed views to solve contention or speed issues in an OLTP? How come I've never seen this in use?</strong></p>