I have to update >100GB of data of jsonb values in a postgres DB that have the following structure:
{
"attributes": [
{
"attribute": "foobar",
"rules":[
{
"label": "rule1"
},
{
"label": "rule2"
}
]
},
{
"attribute": "foobar2",
"rules":[
{
"label": "rule1"
},
{
"label": "rule2"
}
]
}
]
}
I have to iterate through all attributes and remove from the rules array the object that has label with value rule2.
I have created a plsql script that iterates through each attribute and removes it with
jsonb_set(attributes, attributes #> attribute_id, attributes #> attribute_id - attribute_rule_id)
but it is taking too long. How would you approach this problem? Thanks!
New contributor
Nirm is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.