EXPLAIN (ANALYZE, BUFFERS)
SELECT edit.id, edit.editor, edit.open_time, edit.expire_time,
       edit.close_time, edit.data, edit.language, edit.type, edit.yes_votes,
       edit.no_votes, edit.autoedit, edit.status, edit.quality
  FROM edit
 WHERE edit.id IN
       (SELECT er.edit
          FROM edit_release er
               JOIN editor_collection_release ecr
               ON er.release = ecr.release
         WHERE ecr.collection = COLL_ID
         UNION
        SELECT ee.edit
          FROM edit_event ee
               JOIN editor_collection_event ece
               ON ee.event = ece.event
         WHERE ece.collection = COLL_ID)
ORDER BY edit.id DESC
LIMIT 500;

EXPLAIN (ANALYZE, BUFFERS)
SELECT edit.id, edit.editor, edit.open_time, edit.expire_time,
       edit.close_time, edit.data, edit.language, edit.type, edit.yes_votes,
       edit.no_votes, edit.autoedit, edit.status, edit.quality
  FROM edit
 WHERE edit.id IN
       (SELECT er.edit
          FROM edit_release er
               JOIN editor_collection_release ecr
               ON er.release = ecr.release
         WHERE ecr.collection = COLL_ID
         UNION
        SELECT ee.edit
          FROM edit_event ee
               JOIN editor_collection_event ece
               ON ee.event = ece.event
         WHERE ece.collection = COLL_ID)
ORDER BY edit.id DESC
LIMIT 500;


EXPLAIN (ANALYZE, BUFFERS)
SELECT DISTINCT edit.id, edit.editor, edit.open_time, edit.expire_time,
       edit.close_time, edit.data, edit.language, edit.type, edit.yes_votes,
       edit.no_votes, edit.autoedit, edit.status, edit.quality
  FROM edit
 WHERE edit.id IN
       (SELECT er.edit
          FROM edit_release er
               JOIN editor_collection_release ecr
               ON er.release = ecr.release
         WHERE ecr.collection = COLL_ID
         UNION
        SELECT ee.edit
          FROM edit_event ee
               JOIN editor_collection_event ece
               ON ee.event = ece.event
         WHERE ece.collection = COLL_ID)
ORDER BY edit.id DESC
LIMIT 500;

EXPLAIN (ANALYZE, BUFFERS)
SELECT DISTINCT edit.id, edit.editor, edit.open_time, edit.expire_time,
       edit.close_time, edit.data, edit.language, edit.type, edit.yes_votes,
       edit.no_votes, edit.autoedit, edit.status, edit.quality
  FROM edit
 WHERE edit.id IN
       (SELECT er.edit
          FROM edit_release er
               JOIN editor_collection_release ecr
               ON er.release = ecr.release
         WHERE ecr.collection = COLL_ID
         UNION
        SELECT ee.edit
          FROM edit_event ee
               JOIN editor_collection_event ece
               ON ee.event = ece.event
         WHERE ece.collection = COLL_ID)
ORDER BY edit.id DESC
LIMIT 500;


EXPLAIN (ANALYZE, BUFFERS)
SELECT DISTINCT edit.id, edit.editor, edit.open_time, edit.expire_time,
       edit.close_time, edit.data, edit.language, edit.type, edit.yes_votes,
       edit.no_votes, edit.autoedit, edit.status, edit.quality
  FROM edit
 WHERE edit.id IN
       (SELECT er.edit
          FROM edit_release er
               JOIN editor_collection_release ecr
               ON er.release = ecr.release
         WHERE ecr.collection = COLL_ID
         UNION ALL
        SELECT ee.edit
          FROM edit_event ee
               JOIN editor_collection_event ece
               ON ee.event = ece.event
         WHERE ece.collection = COLL_ID)
ORDER BY edit.id DESC
LIMIT 500;

EXPLAIN (ANALYZE, BUFFERS)
SELECT DISTINCT edit.id, edit.editor, edit.open_time, edit.expire_time,
       edit.close_time, edit.data, edit.language, edit.type, edit.yes_votes,
       edit.no_votes, edit.autoedit, edit.status, edit.quality
  FROM edit
 WHERE edit.id IN
       (SELECT er.edit
          FROM edit_release er
               JOIN editor_collection_release ecr
               ON er.release = ecr.release
         WHERE ecr.collection = COLL_ID
         UNION ALL
        SELECT ee.edit
          FROM edit_event ee
               JOIN editor_collection_event ece
               ON ee.event = ece.event
         WHERE ece.collection = COLL_ID)
ORDER BY edit.id DESC
LIMIT 500;


EXPLAIN (ANALYZE, BUFFERS)
SELECT edit.id, edit.editor, edit.open_time, edit.expire_time,
       edit.close_time, edit.data, edit.language, edit.type, edit.yes_votes,
       edit.no_votes, edit.autoedit, edit.status, edit.quality
  FROM edit
 WHERE EXISTS (SELECT 1
          FROM edit_release er
               JOIN editor_collection_release ecr
               ON er.release = ecr.release
         WHERE er.edit = edit.id AND ecr.collection = COLL_ID)
       OR EXISTS (SELECT 1
          FROM edit_event ee
               JOIN editor_collection_event ece
               ON ee.event = ece.event
         WHERE ee.edit = edit.id AND ece.collection = COLL_ID)
ORDER BY edit.id DESC
LIMIT 500;

EXPLAIN (ANALYZE, BUFFERS)
SELECT edit.id, edit.editor, edit.open_time, edit.expire_time,
       edit.close_time, edit.data, edit.language, edit.type, edit.yes_votes,
       edit.no_votes, edit.autoedit, edit.status, edit.quality
  FROM edit
 WHERE EXISTS (SELECT 1
          FROM edit_release er
               JOIN editor_collection_release ecr
               ON er.release = ecr.release
         WHERE er.edit = edit.id AND ecr.collection = COLL_ID)
       OR EXISTS (SELECT 1
          FROM edit_event ee
               JOIN editor_collection_event ece
               ON ee.event = ece.event
         WHERE ee.edit = edit.id AND ece.collection = COLL_ID)
ORDER BY edit.id DESC
LIMIT 500;
