title: Cannot understand PostgreSQL Documentation regarding FOR UPDATE row lock
body: <blockquote>
  <p>When a locking clause appears in a sub-SELECT, the rows locked are those returned to the outer query by the sub-query. This might involve fewer rows than inspection of the sub-query alone would suggest, since conditions from the outer query might be used to optimize execution of the sub-query. For example,</p>
  <p><code>SELECT * FROM (SELECT * FROM mytable FOR UPDATE) ss WHERE col1 = 5;</code>
  will lock only rows having col1 = 5, even though that condition is not textually within the sub-query.</p>
  </blockquote>
  <p>Can somebody please help me understand the sentence &quot;This might involve fewer rows than inspection of the sub-query alone would suggest, since conditions from the outer query might be used to optimize execution of the sub-query&quot;?</p>
  <p>My understanding is that &quot;the rows locked are those returned to the outer query by the sub-query&quot; so whatever subquery return (in this case all rows), those rows must be lock? Why is it that only co1 = 5 is locked</p>