| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Database.CQL.IO.PrepQuery
Synopsis
- data PrepQuery k a b
- prepared :: QueryString k a b -> PrepQuery k a b
- queryString :: PrepQuery k a b -> QueryString k a b
- data PreparedQueries
- new :: IO PreparedQueries
- lookupQueryId :: PrepQuery k a b -> PreparedQueries -> STM (Maybe (QueryId k a b))
- lookupQueryString :: QueryId k a b -> PreparedQueries -> STM (Maybe (QueryString k a b))
- insert :: PrepQuery k a b -> QueryId k a b -> PreparedQueries -> STM ()
- delete :: PrepQuery k a b -> PreparedQueries -> STM ()
- queryStrings :: PreparedQueries -> STM [Text]
Documentation
Representation of a prepared QueryString. A prepared query is
executed in two stages:
- The query string is sent to a server without parameters for
preparation. The server responds with a
QueryId. - The prepared query is executed by sending the
QueryIdand parameters to the server.
Thereby step 1 is only performed when the query has not yet been prepared with the host (coordinator) used for query execution. Thus, prepared queries enhance performance by avoiding the repeated sending and parsing of query strings.
Query preparation is handled transparently by the client.
See setPrepareStrategy.
Note
Prepared statements are fully supported but rely on some assumptions beyond the scope of the CQL binary protocol specification (spec):
- The spec scopes the
QueryIdto the node the query has been prepared with. The spec does not state anything about the format of theQueryId. However the official Java driver assumes that any givenQueryStringyields the sameQueryIdon every node. This client make the same assumption. - In case a node does not know a given
QueryIdanUnpreparederror is returned. We assume that it is always safe to transparently re-prepare the correspondingQueryStringand to re-execute the original request against the same node.
Besides these assumptions there is also a potential tradeoff in
regards to eager vs. lazy query preparation.
We understand eager to mean preparation against all current nodes of
a cluster and lazy to mean preparation against a single node on demand,
i.e. upon receiving an Unprepared error response. Which strategy to
choose depends on the scope of query reuse and the size of the cluster.
The global default can be changed through the Settings module as well
as locally using withPrepareStrategy.
Instances
| IsString (PrepQuery k a b) Source # | |
Defined in Database.CQL.IO.PrepQuery Methods fromString :: String -> PrepQuery k a b # | |
prepared :: QueryString k a b -> PrepQuery k a b Source #
queryString :: PrepQuery k a b -> QueryString k a b Source #
data PreparedQueries Source #
new :: IO PreparedQueries Source #
lookupQueryId :: PrepQuery k a b -> PreparedQueries -> STM (Maybe (QueryId k a b)) Source #
lookupQueryString :: QueryId k a b -> PreparedQueries -> STM (Maybe (QueryString k a b)) Source #
queryStrings :: PreparedQueries -> STM [Text] Source #