Re: Removing a key from jsonb is sloooow

From: Tumasgiu Rossini <rossini(dot)t(at)gmail(dot)com>
To: Volkan Unsal <spocksplanet(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Removing a key from jsonb is sloooow
Date: 2019-07-17 14:40:26
Message-ID: CAJD9AWy1AsBaw8j-0E=4oRLKfEpyVGmv1tgrkZOZ=NzZV2EMmQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

Your current query actually process your 10K rows,
it is a bit of an overkill if only a few row contains the key you want to
delete.
Depending on how big your json data is, this could be problematic.

Have you considered adding a where clause to your query ?

Also, maybe you could create an index on your jsonb column
to improve the identification of rows which
contains the key you want to delete ?

Le mer. 17 juil. 2019 à 16:31, Volkan Unsal <spocksplanet(at)gmail(dot)com> a
écrit :

> I'm trying to remove a key from a jsonb column in a table with 10K rows,
> and the performance is abysmal. When the key is missing, it takes 5
> minutes. When the key is present, it takes even longer.
>
> Test with non-existent key:
>
> >> update projects set misc = misc - 'foo';
> Time: 324711.960 ms (05:24.712)
>
> What can I do to improve this?
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2019-07-17 15:01:02 Re: Removing a key from jsonb is sloooow
Previous Message Adrian Klaver 2019-07-17 14:39:36 Re: Removing a key from jsonb is sloooow