Top Description Fields Constructors Methods
org.postgresql.core.v3.adaptivefetch

public Class AdaptiveFetchCache

extends Object
Class Inheritance
Imports
org.postgresql.PGProperty, org.postgresql.core.Query, java.sql.SQLException, java.util.HashMap, .Map, .Properties

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.

Field Summary

Modifier and TypeField and Description
private boolean
private final Map<String, AdaptiveFetchCacheEntry>
private int
private long
private final int

Constructor Summary

AccessConstructor and Description
public
AdaptiveFetchCache(long maximumResultBufferSize, Properties info)

Method Summary

Modifier and TypeMethod and Description
public void
addNewQuery(boolean
state of adaptive fetch, which should be used during adding query
adaptiveFetch
,
Query
query to be cached
query
)

Add query to being cached and computing adaptive fetch size.

private int

Returns:

value which meet the constraints
adjustFetchSize
(int
value which should be the computed fetch size
actualSize
)

Set maximum and minimum constraints on given value.

private int

Returns:

value which meet the maximum constraint
adjustMaximumFetchSize
(int
value which should be the computed fetch size
actualSize
)

Set maximum constraint on given value.

private int

Returns:

value which meet the minimum constraint
adjustMinimumFetchSize
(int
value which should be the computed fetch size
actualSize
)

Set minimum constraint on given value.

public boolean

Returns:

state of adaptive fetch
getAdaptiveFetch
()

Get state of adaptive fetch.

public int

Returns:

adaptive fetch size for query or -1 if size doesn't exist/adaptive fetch state is false
getFetchSizeForQuery
(boolean
state of adaptive fetch, which should be used during getting fetch size for query
adaptiveFetch
,
Query
query to which we want get adaptive fetch size
query
)

Get adaptive fetch size for given query.

public void
removeQuery(boolean
state of adaptive fetch, which should be used during removing fetch size for query
adaptiveFetch
,
Query
query to be removed from caching
query
)

Remove query information from caching.

public void
setAdaptiveFetch(boolean
desired state of adaptive fetch
adaptiveFetch
)

Set state of adaptive fetch.

public void
updateQueryFetchSize(boolean
state of adaptive fetch, which should be used during updating fetch size for query
adaptiveFetch
,
Query
query to be updated
query
,
int
max row size used during updating information about adaptive fetch size for given query
maximumRowSizeBytes
)

Update adaptive fetch size for given query.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

adaptiveFetchback to summary
private boolean adaptiveFetch
adaptiveFetchInfoMapback to summary
private final Map<String, AdaptiveFetchCacheEntry> adaptiveFetchInfoMap
maximumAdaptiveFetchSizeback to summary
private int maximumAdaptiveFetchSize
maximumResultBufferSizeback to summary
private long maximumResultBufferSize
minimumAdaptiveFetchSizeback to summary
private final int minimumAdaptiveFetchSize

Constructor Detail

AdaptiveFetchCacheback to summary
public AdaptiveFetchCache(long maximumResultBufferSize, Properties info) throws SQLException

Method Detail

addNewQueryback to summary
public void addNewQuery(boolean adaptiveFetch, Query query)

Add query to being cached and computing adaptive fetch size.

Parameters
adaptiveFetch:boolean

state of adaptive fetch, which should be used during adding query

query:Query

query to be cached

adjustFetchSizeback to summary
private int adjustFetchSize(int actualSize)

Set maximum and minimum constraints on given value.

Parameters
actualSize:int

value which should be the computed fetch size

Returns:int

value which meet the constraints

adjustMaximumFetchSizeback to summary
private int adjustMaximumFetchSize(int actualSize)

Set maximum constraint on given value.

Parameters
actualSize:int

value which should be the computed fetch size

Returns:int

value which meet the maximum constraint

adjustMinimumFetchSizeback to summary
private int adjustMinimumFetchSize(int actualSize)

Set minimum constraint on given value.

Parameters
actualSize:int

value which should be the computed fetch size

Returns:int

value which meet the minimum constraint

getAdaptiveFetchback to summary
public boolean getAdaptiveFetch()

Get state of adaptive fetch.

Returns:boolean

state of adaptive fetch

getFetchSizeForQueryback to summary
public int getFetchSizeForQuery(boolean adaptiveFetch, Query query)

Get adaptive fetch size for given query.

Parameters
adaptiveFetch:boolean

state of adaptive fetch, which should be used during getting fetch size for query

query:Query

query to which we want get adaptive fetch size

Returns:int

adaptive fetch size for query or -1 if size doesn't exist/adaptive fetch state is false

removeQueryback to summary
public void removeQuery(boolean adaptiveFetch, Query query)

Remove query information from caching.

Parameters
adaptiveFetch:boolean

state of adaptive fetch, which should be used during removing fetch size for query

query:Query

query to be removed from caching

setAdaptiveFetchback to summary
public void setAdaptiveFetch(boolean adaptiveFetch)

Set state of adaptive fetch.

Parameters
adaptiveFetch:boolean

desired state of adaptive fetch

updateQueryFetchSizeback to summary
public void updateQueryFetchSize(boolean adaptiveFetch, Query query, int maximumRowSizeBytes)

Update adaptive fetch size for given query.

Parameters
adaptiveFetch:boolean

state of adaptive fetch, which should be used during updating fetch size for query

query:Query

query to be updated

maximumRowSizeBytes:int

max row size used during updating information about adaptive fetch size for given query