postgresql prepared statements with JSONB containment I'm trying to write a prepared statement using a date held in JSONB.  A prepared statement doesn't allow the containment operator @&gt; so I used the function name itself jsonb_contains which executes, but now postgres doesn't use the gin index.
Testing in a psql session performance is excellent when I do this
select * 
from tab 
where jsonb_obj @&gt; '{&quot;date_el&quot;:&quot;2001-01-31&quot;}'

because it uses the gin index.  But that won't parse in a prepared statement in java.
When I run this in psql:
select * 
from tab 
where jsonb_contains(jsonb_obj-&gt;&gt;'date_el', '2001-01-31')

performance is very bad.
Has anyone ever had this problem?
the error we see is &quot;operator does not exist: jsonb @&gt; text&quot;

I assume you are passing the JSON string via PreparedStatement.setString().
Postgres expects a JSONB value, not a text value. You can easily overcome this by casting the parameter to a jsonb:
select * 
from tab 
where jsonb_obj @&gt; cast(? as jsonb)