This there a performance hit on creating a index on a jsonb column? Reason is I have a very large data set which I want to query. the set up is that my java models (very large) are stored as blobs in a jsonb column in my database. Now I want to pull reports based on conditions on the data inside the payload data. So I want to know whether there will be a performance hit on my prod db when trying to pull these stats? Would adding an index help with this query?
CREATE VIEW Reporting_View AS
Select dms.key AS "Id",
dms.data_model_type AS Data_Model_Type,
dms.short_type_name AS Short_Type_Name,
dms.version AS "Version",
dms.payload_data -> 'requestData' ->> 'modelType' AS Model_Type,
dms.payload_data -> 'requestData' ->> 'modelName' AS Model_Name,
dms.payload_data -> 'requestData' ->> 'modelVersion' AS Model_Version,
dms.payload_data -> 'requestData' -> 'arguments' ->> 'age' AS Age,
dms.payload_data -> 'requestData' -> 'arguments' ->> 'department' AS Department,
dms.payload_data -> 'requestData' -> 'arguments' ->> 'income' AS Income,
dms.payload_data -> 'output' ->> 'output' AS FinalResult
From myschema.data_model_storage dms;
@>operator can use GIN indexes on the column. Indexes are created to support queries, so without the query, the question can't really be answered. Is there a performance hit creating such an index? Yes, INSERTs, DELETEs and UPDATEs will be slower - how much slower depends on a lot of factors.