From: | Keith <keith(at)keithf4(dot)com> |
---|---|
To: | pavan95 <pavan(dot)postgresdba(at)gmail(dot)com> |
Cc: | pgsql-admin <pgsql-admin(at)postgresql(dot)org> |
Subject: | Re: Can we exclude errors of some particular text in Postgres log file? |
Date: | 2018-09-01 15:57:28 |
Message-ID: | CAHw75vsYG8XM=Peg0Pz17dacDKgdSRhPq0p0kyy8bpGuHNzeTg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
On Sat, Sep 1, 2018 at 6:14 AM, pavan95 <pavan(dot)postgresdba(at)gmail(dot)com> wrote:
> Hi Team,
>
> Can we exclude errors of a particular type from the postgres log file ?
>
> For example:
> ERROR: duplicate key value violates unique constraint "table_uniq"
> DETAIL: Key (column1, column2, column3)=(value0, value1, 1) already
> exists.
>
> If yes, how can we exclude this errors from the pg_log files. Suggest me an
> approach.
>
> Thanks in Advance.
>
> Regards,
> Pavan
>
>
>
>
>
> --
> Sent from: http://www.postgresql-archive.org/PostgreSQL-admin-f2076596.
> html
>
>
I suggest upgrading to at least PostgreSQL 9.5 if you haven't already and
look into the INSERT...ON CONFLICT feature (also called UPSERT). With it
you can define what happens if an insert would violate a defined constraint
and instead update the given row, do nothing or a wide variety of other
operations.
https://www.postgresql.org/docs/current/static/sql-insert.html
If this doesn't fit the model that is causing your duplicate key errors,
you may want to look into using a function to do your writes instead and
catch the given error in an exception block and then just ignore it.
Keith
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2018-09-01 16:01:46 | Re: Can we exclude errors of some particular text in Postgres log file? |
Previous Message | Tom Lane | 2018-09-01 14:43:55 | Re: pg_dump and disk full |