title: How can I capture the number of rows inserted into a Redshift table which contains an identity column?
body: <p>In Amazon Redshift, I'm using the following query to capture the number of rows inserted by the last query: </p>
  
  <pre><code>SELECT SUM(rows) FROM stl_insert WHERE query = pg_last_query_id();
  </code></pre>
  
  <p>It seems that this approach doesn't work when I insert into a table that contains an IDENTITY column, because Redshift also runs this query: SELECT * FROM stv_identity_highwater and uses this query's id for pg_last_query_id().</p>
  
  <p>Is there another way to capture the number of rows inserted in this scenario?</p>