title: what could be the reason for high "SQL Server parse and compile time"?
body: <p>a little background first: </p>
  
  <p>i have a legacy application with security rules inside the app.<br> 
  to reuse the database model with an addition app on this model with integreated security model inside! the database, i deside to use views with the security rules inside the view sql.<br>the logic works well but the perf was not really good (high io cause by scan some/many tbls).<br>so i use indexed views instead of standard views for the basic coles i need for the security and add additional a view on top of the index view with security rules. works perfect when i see the io perf.<br><br>but now o have a poor parse and compile time.</p>
  
  <p>when i erase all buffers a simple sql against the top view deliver this timings:</p>
  
  <pre>
  "SQL Server-Analyse- und Kompilierzeit: 
  , CPU-Zeit = 723 ms, verstrichene Zeit = 723 ms.
  
  -----------
  7
  
  (1 Zeile(n) betroffen)
  
  #A7F38F33-Tabelle. Scananzahl 1, logische Lesevorgänge 7, physische Lesevorgänge 0, Read-Ahead-Lesevorgänge 0, logische LOB-Lesevorgänge 0, physische LOB-Lesevorgänge 0, Read-Ahead-LOB-Lesevorgänge 0.
  xADSDocu-Tabelle. Scananzahl 1, logische Lesevorgänge 2, physische Lesevorgänge 0, Read-Ahead-Lesevorgänge 0, logische LOB-Lesevorgänge 0, physische LOB-Lesevorgänge 0, Read-Ahead-LOB-Lesevorgänge 0.
  
   SQL Server-Ausführungszeiten: 
  , CPU-Zeit = 0 ms, verstrichene Zeit = 0 ms.
  </pre>
  
  <p>when i execute the same stmt again the parsetime is of course zero.<br>
  in past i see sometimes later with the same statement a very long parse time again when i reexecute it >1sec (no dml is done during this time!).<br>now i have deactivate all statistics automatisations and never see this long parse times again.
  <br><br>
  but what could be the reason for so a long initial parse and compile time?<br> this time is very huge and cause a very bad perf on the app itselve with this solution.<br><br>
  is there a way to look deeper inside the parse time to find the root cause for it?</p>