Class QueryOptions
Options related to defaults for individual queries.
Inheritance
Inherited Members
Namespace: Dse
Assembly: Dse.dll
Syntax
public class QueryOptions
Fields
DefaultConsistencyLevel
The default consistency level for queries: ConsistencyLevel.LocalOne
.
For DataStax Astra, this constant should be ignored as the default is LocalQuorum.
Declaration
public const ConsistencyLevel DefaultConsistencyLevel = ConsistencyLevel.LocalOne
Field Value
Type | Description |
---|---|
ConsistencyLevel |
DefaultPageSize
The default page size for SELECT queries: 5000.
Declaration
public const int DefaultPageSize = 5000
Field Value
Type | Description |
---|---|
System.Int32 |
DefaultRetryOnTimeout
Default value for RetryOnTimeout
Declaration
public const bool DefaultRetryOnTimeout = true
Field Value
Type | Description |
---|---|
System.Boolean |
DefaultSerialConsistencyLevel
The default serial consistency level for conditional updates: ConsistencyLevel.Serial
.
Declaration
public const ConsistencyLevel DefaultSerialConsistencyLevel = ConsistencyLevel.Serial
Field Value
Type | Description |
---|---|
ConsistencyLevel |
Properties
RetryOnTimeout
Gets a value that determines if the client should retry when it didn't hear back from a host within ReadTimeoutMillis.
DEPRECATED: Instead, use OnRequestError(IStatement, Configuration, Exception, Int32) to control the behavior when OperationTimedOutException is obtained.
Declaration
public bool RetryOnTimeout { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
GetConsistencyLevel()
The default consistency level used by queries.
Declaration
public ConsistencyLevel GetConsistencyLevel()
Returns
Type | Description |
---|---|
ConsistencyLevel | the default consistency level used by queries. |
GetDefaultIdempotence()
Gets the default idempotence for all queries.
Declaration
public bool GetDefaultIdempotence()
Returns
Type | Description |
---|---|
System.Boolean |
GetPageSize()
The default page size used by queries.
Declaration
public int GetPageSize()
Returns
Type | Description |
---|---|
System.Int32 | the default page size used by queries. |
GetSerialConsistencyLevel()
The default serial consistency level used by queries.
Declaration
public ConsistencyLevel GetSerialConsistencyLevel()
Returns
Type | Description |
---|---|
ConsistencyLevel | the default serial consistency level used by queries. |
IsPrepareOnAllHosts()
Determines whether the driver should prepare statements on all hosts in the cluster.
Declaration
public bool IsPrepareOnAllHosts()
Returns
Type | Description |
---|---|
System.Boolean |
IsReprepareOnUp()
Determines whether the driver should re-prepare all cached prepared statements on a host when its marks that host back up.
Declaration
public bool IsReprepareOnUp()
Returns
Type | Description |
---|---|
System.Boolean |
SetConsistencyLevel(ConsistencyLevel)
Sets the default consistency level to use for queries.
The consistency level set through this method will be use for queries that don't explicitely have a consistency level.
Declaration
public QueryOptions SetConsistencyLevel(ConsistencyLevel consistencyLevel)
Parameters
Type | Name | Description |
---|---|---|
ConsistencyLevel | consistencyLevel | the new consistency level to set as default. |
Returns
Type | Description |
---|---|
QueryOptions | this QueryOptions instance |
SetDefaultIdempotence(Boolean)
Sets the default idempotence for all queries.
Declaration
public QueryOptions SetDefaultIdempotence(bool idempotence)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | idempotence |
Returns
Type | Description |
---|---|
QueryOptions |
SetPageSize(Int32)
Sets the default page size to use for SELECT queries. The page size set through this method will be use for queries that don't explicitely have a page size.
Declaration
public QueryOptions SetPageSize(int pageSize)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pageSize | the new page size to set as default. It must be strictly positive but you can use int.MaxValue to disable paging. |
Returns
Type | Description |
---|---|
QueryOptions | this QueryOptions instance |
SetPrepareOnAllHosts(Boolean)
Sets whether the driver should prepare statements on all hosts in the cluster.
A statement is normally prepared in two steps: prepare the query on a single host in the cluster; if that succeeds, prepare on all other hosts.
This option controls whether step 2 is executed. It is enabled by default.
Declaration
public QueryOptions SetPrepareOnAllHosts(bool prepareOnAllHosts)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | prepareOnAllHosts |
Returns
Type | Description |
---|---|
QueryOptions |
Remarks
The reason why you might want to disable it is to optimize network usage if you have a large number of clients preparing the same set of statements at startup. If your load balancing policy distributes queries randomly, each client will pick a different host to prepare its statements, and on the whole each host has a good chance of having been hit by at least one client for each statement.
On the other hand, if that assumption turns out to be wrong and one host hasn't prepared a given statement, it needs to be re-prepared on the fly the first time it gets executed; this causes a performance penalty (one extra roundtrip to resend the query to prepare, and another to retry the execution).
SetReprepareOnUp(Boolean)
Set whether the driver should re-prepare all cached prepared statements on a host when it marks it back up.
This option is enabled by default.
Declaration
public QueryOptions SetReprepareOnUp(bool reprepareOnUp)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | reprepareOnUp |
Returns
Type | Description |
---|---|
QueryOptions |
Remarks
The reason why you might want to disable it is to optimize reconnection time when you believe hosts often get marked down because of temporary network issues, rather than the host really crashing. In that case, the host still has prepared statements in its cache when the driver reconnects, so re-preparing is redundant.
On the other hand, if that assumption turns out to be wrong and the host had really restarted, its prepared statement cache is empty, and statements need to be re-prepared on the fly the first time they get executed; this causes a performance penalty (one extra roundtrip to resend the query to prepare, and another to retry the execution).
SetRetryOnTimeout(Boolean)
Determines if the client should retry when it didn't hear back from a host within ReadTimeoutMillis.
DEPRECATED: Instead, use OnRequestError(IStatement, Configuration, Exception, Int32) to control the behavior when OperationTimedOutException is obtained.
Declaration
public QueryOptions SetRetryOnTimeout(bool retry)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | retry |
Returns
Type | Description |
---|---|
QueryOptions |
SetSerialConsistencyLevel(ConsistencyLevel)
Sets the default serial consistency level to use for queries. The serial consistency level set through this method will be use for queries that don't explicitely have a serial consistency level.
Declaration
public QueryOptions SetSerialConsistencyLevel(ConsistencyLevel serialConsistencyLevel)
Parameters
Type | Name | Description |
---|---|---|
ConsistencyLevel | serialConsistencyLevel | the new serial consistency level to set as default. |
Returns
Type | Description |
---|---|
QueryOptions | this QueryOptions instance. |