title: Postgresql -> deadlock from simple update. I can't get the cause
body: <p>Here is table ( simplified ):</p>
  
  <pre>
                                         Table "public.link"
      Column     |            Type             |                     Modifiers                     
  ---------------+-----------------------------+---------------------------------------------------
   id            | integer                     | not null default nextval('link_id_seq'::regclass)
   page_id       | integer                     | 
   placed_at     | timestamp without time zone | default now()
  Indexes:
      "link_pkey" PRIMARY KEY, btree (id)
      "link_page_id_index" btree (page_id)
  Foreign-key constraints:
      "link_page_id_foreign_key" FOREIGN KEY (page_id) REFERENCES page(id) ON UPDATE RESTRICT ON DELETE RESTRICT
  </pre>
  
  <p>And here is query ( simplified ):</p>
  
  <pre>
  UPDATE link SET page_id = ?, placed_at = now() <br />WHERE id IN ( SELECT id FROM link ... ) AND page_id IS NOT NULL
  </pre>
  
  <p>Deadlock message:</p>
  
  <pre>
  ERROR: deadlock detected
    Detail: Process 5822 waits for ShareLock on transaction 19705; blocked by process 5821.
  Process 5821 waits for ShareLock on transaction 19706; blocked by process 5822.
    Hint: See server log for query details.
  </pre>
  
  <p><b>How can that query, executed in parallel by several processes, lead to deadlock ?</b><br />
  Thanks!</p>