Prepared statements cache should not take bound values into account

Description

See for context.

Currently the prepared statement cache (see here) uses PreparedRequest instances as its keys.

Such instances hold a SimpleStatement instance, which in turn, may contain bound values, and these are included in the DefaultSimpleStatement class' equals and hashCode methods.

The result is that two identical SimpleStatement instances differing only by their bound values will create two distinct keys in the cache, possibly causing the cache to grow uncontrollably.

But bound values are irrelevant in this context. We could explore a few ideas to improve this:

  1. Just make it clear in the javadocs that the statement being prepared should be a template, that is, it should contain bind markers but no bound value.

  2. Amend the constructor DefaultPrepareRequest(SimpleStatement) and explicitly remove the bound values:

Environment

None

Pull Requests

None

Activity

Details

Assignee

Reporter

Priority

Created February 21, 2022 at 1:30 PM
Updated February 21, 2022 at 1:30 PM