Can we create index for key/value of JSONB data type?
I suggest an expression index on the value of the key 'x_id', cast to bigint - plain (default) btree, not GIN. A specific difficulty here: the short notation for type casts would need multiple layers of parentheses to make the syntax work for index creation. 

CREATE INDEX y_data_xid_idx ON y (((y.data-&gt;&gt;'x_id')::bigint));


Rather use the explicit form (to the same effect):

CREATE INDEX y_data_xid_idx ON y (cast(y.data-&gt;&gt;'x_id' AS bigint));