Class AdaptiveFetchCache
java.lang.Object
org.postgresql.core.v3.adaptivefetch.AdaptiveFetchCache
The main purpose of this class is to handle adaptive fetching process. Adaptive fetching is used
to compute fetch size to fully use size defined by maxResultBuffer. Computing is made by dividing
maxResultBuffer size by max row result size noticed so far. Each query have separate adaptive
fetch size computed, but same queries have it shared. If adaptive fetch is turned on, first fetch
is going to be made with defaultRowFetchSize, next fetching of resultSet will be made with
computed adaptive fetch size. If adaptive fetch is turned on during fetching, then first fetching
made by ResultSet will be made with defaultRowFetchSize, next will use computed adaptive fetch
size. Property adaptiveFetch need properties defaultRowFetchSize and maxResultBuffer to work.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addNewQuery
(boolean adaptiveFetch, @NonNull Query query) Add query to being cached and computing adaptive fetch size.boolean
Get state of adaptive fetch.int
getFetchSizeForQuery
(boolean adaptiveFetch, @NonNull Query query) Get adaptive fetch size for given query.void
removeQuery
(boolean adaptiveFetch, @NonNull Query query) Remove query information from caching.void
setAdaptiveFetch
(boolean adaptiveFetch) Set state of adaptive fetch.void
updateQueryFetchSize
(boolean adaptiveFetch, @NonNull Query query, int maximumRowSizeBytes) Update adaptive fetch size for given query.
-
Constructor Details
-
AdaptiveFetchCache
- Throws:
SQLException
-
-
Method Details
-
addNewQuery
Add query to being cached and computing adaptive fetch size.- Parameters:
adaptiveFetch
- state of adaptive fetch, which should be used during adding queryquery
- query to be cached
-
updateQueryFetchSize
public void updateQueryFetchSize(boolean adaptiveFetch, @NonNull Query query, int maximumRowSizeBytes) Update adaptive fetch size for given query.- Parameters:
adaptiveFetch
- state of adaptive fetch, which should be used during updating fetch size for queryquery
- query to be updatedmaximumRowSizeBytes
- max row size used during updating information about adaptive fetch size for given query
-
getFetchSizeForQuery
Get adaptive fetch size for given query.- Parameters:
adaptiveFetch
- state of adaptive fetch, which should be used during getting fetch size for queryquery
- query to which we want get adaptive fetch size- Returns:
- adaptive fetch size for query or -1 if size doesn't exist/adaptive fetch state is false
-
removeQuery
Remove query information from caching.- Parameters:
adaptiveFetch
- state of adaptive fetch, which should be used during removing fetch size for queryquery
- query to be removed from caching
-
getAdaptiveFetch
public boolean getAdaptiveFetch()Get state of adaptive fetch.- Returns:
- state of adaptive fetch
-
setAdaptiveFetch
public void setAdaptiveFetch(boolean adaptiveFetch) Set state of adaptive fetch.- Parameters:
adaptiveFetch
- desired state of adaptive fetch
-