From: | Durgamahesh Manne <maheshpostgres9(at)gmail(dot)com> |
---|---|
To: | Greg Sabino Mullane <htamfids(at)gmail(dot)com> |
Cc: | pgsql-general(at)lists(dot)postgresql(dot)org, pgsql-in-general(at)postgresql(dot)org, Christoph Berg <myon(at)debian(dot)org>, laurenz(dot)albe(at)cybertec(dot)at, semab tariq <semabtariq1(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Performance degrade on insert on conflict do nothing |
Date: | 2024-09-12 14:23:45 |
Message-ID: | CAJCZko+jsuNP5z5dRem0oowiB_F25Q4_pOAAuFiG5pvUYTfbaA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-in-general |
Hi Greg
Great response from you this worked
Regards
Durga Mahesh
On Wed, Sep 11, 2024 at 7:12 PM Greg Sabino Mullane <htamfids(at)gmail(dot)com>
wrote:
> On Wed, Sep 11, 2024 at 1:02 AM Durgamahesh Manne <
> maheshpostgres9(at)gmail(dot)com> wrote:
>
>> Hi
>> createdat | timestamp with time zone | | not null | now()
>> | plain | | |
>> modified | timestamp with time zone | | not null | now()
>> | plain | | |
>> Triggers:
>> i_dictionary_createdat BEFORE INSERT ON dictionary FOR EACH ROW
>> EXECUTE FUNCTION update_createdat_col()
>> i_dictionary_modified BEFORE INSERT OR UPDATE ON dictionary FOR EACH
>> ROW EXECUTE FUNCTION update_modified_col()
>>
>
>
>> How do we improve this query performance without taking more cpu?
>>
>
> 1. Lose the first trigger. I don't know exactly what those functions do,
> but if they are only for updating those columns, just remove the first one
> and let postgres handle it via NOT NULL DEFAULT.
>
> 2. Change the second trigger to just ON UPDATE
>
> 3. Remove that second trigger as well, and have the app populate that
> column (assuming that is all it does), e.g. UPDATE dictionary SET lang =
> 'foo', modified = DEFAULT, modified_by = 'foo' where tid = 12345;
>
> 4. Remove any indexes you do not absolutely need
>
> Cheers,
> Greg
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Ron Johnson | 2024-09-12 15:08:16 | Better way to process records in bash? |
Previous Message | Tom Lane | 2024-09-12 14:19:48 | Re: RLS and Table Inheritance |
From | Date | Subject | |
---|---|---|---|
Next Message | Durgamahesh Manne | 2024-09-12 17:03:10 | Re: Recommendations on improving the insert on conflict do nothing performance |
Previous Message | Muhammad Usman Khan | 2024-09-12 04:35:38 | Re: Recommendations on improving the insert on conflict do nothing performance |