     @query query, (err, result) ->
       return callback err if err
 
+      data = { byTarget: {} }
+      for row in result.rows
+        row.parent_sha1s = Queries.parseArray(row.parent_sha1s)
+        data.byTarget[row.target_sha1] = row
+
       commits = []
-      for row in result.rows
-        row.parent_sha1s = Queries.parseArray(row.parent_sha1s)
-        commits.push new Commit( row )
+      for hash in targetHashes
+        row = data.byTarget[hash]
+        commits.push new Commit( row ) if row
 
       return callback null, commits
 

  # Add a commit to the store.
  # @api public
  addCommit: (commit, callback) ->
    @session (err, session) ->
      return callback err if err

      selectQuery = Queries.selectCommitBySha1(commit.sha1())
      session.query selectQuery, (err, result) ->
        return callback err if err
        return callback null if result.rows.length > 0

        queries = [
          Queries.insertObject(commit)

    @query query, (err, result) ->
      return callback err if err

      data = {}
      for row in result.rows
        row.parent_sha1s = Queries.parseArray(row.parent_sha1s)
        data[row.commit_sha1] = row

      commits = []
      for hash in hashes
        row = data[hash]
        commits.push new Commit( row ) if row

      return callback null, commits

