Unable to search data fast in postgres table
You get that error because data-&gt;'application_form_attributes' is too large to fit in an index entry.

You'd have to index the whole left side of the expression:

CREATE INDEX ON mytable (data-&gt;'application_form_attributes'-&gt;&gt;'5705');


Of course, if '5705' is not a constant, that won't get you far.

With your index, you could change the query to:

... WHERE data-&gt;'application_form_attributes' ? '5705'


but since you cannot create the index, that won't help you.

I don't think that there is an easy way out. Perhaps it would be best to "normalize" the schema, pull those values you want to search for out of the JSON and model it as several tables with foreign key relationship. Then your query will be simpler and perform better, and indexing won't be a problem.