Re: Removing a key from jsonb is sloooow

2019-07-17 Thread Tom Lane
Volkan Unsal writes: > 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. How wide are the jsonb values? It seems likely that most of this is TOAS

Re: Removing a key from jsonb is sloooow

2019-07-17 Thread Adrian Klaver
On 7/17/19 7:59 AM, Volkan Unsal wrote: Aha, it's due to the trigger, isn't it? Yes. On Wed, Jul 17, 2019 at 10:58 AM Volkan Unsal > wrote: @Adrian More information about my setup: Postgres version: PostgreSQL 10.9 (Debian 10.9-1.pgdg90+1) o

Re: Removing a key from jsonb is sloooow

2019-07-17 Thread Volkan Unsal
More information about my setup: Postgres version: PostgreSQL 10.9 (Debian 10.9-1.pgdg90+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516, 64-bit Table schema: CREATE TABLE public.projects ( misc jsonb DEFAULT '{}'::jsonb NOT NULL ); Explain analyze: explain

Re: Removing a key from jsonb is sloooow

2019-07-17 Thread Adrian Klaver
On 7/17/19 7:58 AM, Volkan Unsal wrote: Please post to list also. Ccing list @Adrian More information about my setup: Postgres version: PostgreSQL 10.9 (Debian 10.9-1.pgdg90+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516, 64-bit Table schema: CREATE TABLE

Re: Removing a key from jsonb is sloooow

2019-07-17 Thread Tumasgiu Rossini
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 in

Re: Removing a key from jsonb is sloooow

2019-07-17 Thread Adrian Klaver
On 7/17/19 7:30 AM, Volkan Unsal wrote: 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

Removing a key from jsonb is sloooow

2019-07-17 Thread Volkan Unsal
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.7