title: SQL Server trigger - the same SQL query is slower when inside a trigger
body: <p>One of my database trigger is taking <strong>45 seconds</strong> to execute (I'm timing it by inserting the trigger starting time and ending time in another table, within the code of the trigger, so I'm pretty confident it's not a measurement issue).</p>
  
  <p>But when I execute the same query as the one of the trigger (on the same environment, with the same data), the executing time is now <strong>3 seconds</strong>.</p>
  
  <p>Any idea what could explain and how to investigate such disparity in the execution time, for the same query within a trigger and outside a trigger? (The trigger and the query run on <code>AFTER INSERT</code> and process/insert some rows in another separate table)</p>
  
  <p>TL,DR: why is my trigger slow but the same query fast?</p>