I am using envers at Spring boot project.
@Repository
public interface DataAudRepository extends RevisionRepository<Data, String, Integer>, JpaRepository<Data, String> {
}
If there is numerous data on the data_aud
table (data number : 3500), request of findRevisions(key, pageable)
is very slow.
Sure if there is not numerous data, request is argent.
When Spring call this function, some of hiberate sql occur.
select *
from data_aud publish_au0_
where
data_au0_.rev=(
select max(data_au1_.rev) from data_aud data_au1_
where
data_au1_.rev<=999999 and
data_au0_.data_id=data_au1_.data_id) AND
data_au0_.data_id='my-data-01'
Perhaps i think select max
sequence is reason for slow request.
How to avoid this slow condition?
+)
Primary key of data_aud table is (data_id, varchar(32), rev, int(11))
and PK of data table is data_id.