From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | Philippe VIEGAS <p(dot)viegas(at)loxodata(dot)com> |
Cc: | "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Index scan for PK constraint validation |
Date: | 2023-02-08 13:25:25 |
Message-ID: | CAKFQuwZVT_YQWHY7ppjCuSun0yigmW-u7yQe=OtO6uTAmHS_Mg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wednesday, February 8, 2023, Philippe VIEGAS <p(dot)viegas(at)loxodata(dot)com>
wrote:
> Hi all,
>
> I was wondering why the index statistics usage were not reflecting the
> index usage for primary key constraint validation ?
>
> When we create a table with a primary key, PostgreSQL creates a Btree
> index for the validation of this constraint : index is defined unique
> (indisunique=t) and primary (indisprimary=t) from the pg_index and pg_class
> catalogs.
>
> Inserting data on the above created table and selecting based on the
> primary key column will increment the idx_scan from `pg_stat_user_indexes`
> view.
>
>
The select produces the index scan, not the insert. The insert doesn’t
scan, it populates and aborts if that population fails. It doesn’t check
first.
David J.
From | Date | Subject | |
---|---|---|---|
Next Message | Andrus | 2023-02-08 15:00:10 | How to create directory format backup |
Previous Message | Sebastien Flaesch | 2023-02-08 13:00:21 | Re: Get the sequence name corresponding to a GENERATED { ALWAYS | BY DEFAULT } AS IDENTITY column |