When you include a key from an object stored in my bodyJSONB field , the request runs ~ 100 ms slower than without a field in the selection element:
SELECT id,
title,
body->'_stats' AS stats
FROM items
This takes about 105 ms compared to 5 ms when the selection is statsnot enabled. It doesn't seem to matter which key I return from the JSONB object body, they all slow down the request significantly. There are other keys from the body object that I would like to include in this request, but each of them that I add increases the total request time by ~ 50 ms
The field bodyhas a gin index, and I see the behavior in both PG v9.5x and v9.6.1
Any suggestions on alternative ways to return jsonb object data more efficiently?
source
share