Skip to content

Prepared IN queries should support bind markers #1172

@samueldlightfoot

Description

@samueldlightfoot

Statements generated for IN queries do not use the bindMarker(?) for the collection of values provided for the IN clause. When using prepared statements this means we are creating a prepared statement for each IN query with different parameters. This soon bloats the prepared statement cache when you are selecting by different parameters.

This parameterization is supported in Cassandra:
https://issues.apache.org/jira/browse/CASSANDRA-4210

Expected:
SELECT * FROM Users WHERE id IN ?

Actual:
SELECT * FROM Users WHERE id IN ('id1', 'id2')

Looking in statement factory IN queries that take a collection are handled differently:

		'case IN:

			if (predicate.getValue() instanceof List
					|| (predicate.getValue() != null && predicate.getValue().getClass().isArray())) {
				**return column.in(toLiterals(predicate.getValue()));**
			}

			return column.in(factory.create(predicate.getValue()));`

Example test: 537f96b

I'm happy to have a go at fixing this if we are in agreement it is a bug.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions