Index: hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java =================================================================== --- hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java (revision 1521751) +++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java (working copy) @@ -1433,6 +1433,9 @@ try { // First go to the memstore. Pick up deletes and candidates. this.memstore.getRowKeyAtOrBefore(state); + if (state.hasCandidate() && Bytes.compareTo(state.getCandidate().getRow(), row) == 0) { + return state.getCandidate(); + } // Check if match, if we got a candidate on the asked for 'kv' row. // Process each relevant store file. Run through from newest to oldest. Iterator sfIterator = this.storeEngine.getStoreFileManager() @@ -1442,7 +1445,9 @@ sfIterator.remove(); // Remove sf from iterator. boolean haveNewCandidate = rowAtOrBeforeFromStoreFile(sf, state); if (haveNewCandidate) { - // TODO: we may have an optimization here which stops the search if we find exact match. + if (state.hasCandidate() && Bytes.compareTo(state.getCandidate().getRow(), row) == 0) { + return state.getCandidate(); + } sfIterator = this.storeEngine.getStoreFileManager().updateCandidateFilesForRowKeyBefore( sfIterator, state.getTargetKey(), state.getCandidate()); }