title: Fastest check if row exists in PostgreSQL
body: <p>I have a bunch of rows that I need to insert into table, but these inserts are always done in batches. So I want to check if a single row from the batch exists in the table because then I know they all were inserted.</p>
  
  <p>So its not a primary key check, but shouldn't matter too much. I would like to only check single row so <code>count(*)</code> probably isn't good, so its something like <code>exists</code> I guess.</p>
  
  <p>But since I'm fairly new to PostgreSQL I'd rather ask people who know.</p>
  
  <p>My batch contains rows with following structure:</p>
  
  <pre><code>userid | rightid | remaining_count
  </code></pre>
  
  <p>So if table contains any rows with provided <code>userid</code> it means they all are present there.</p>