Re: Are indices used for creating check constraints?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dinko Papak <rimokatolik(at)outlook(dot)com>
Cc: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Are indices used for creating check constraints?
Date: 2018-10-22 18:12:18
Message-ID: 83722.1540231938@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Dinko Papak <rimokatolik(at)outlook(dot)com> writes:
> Here are 3 interesting (to me) numbers:
> 1. creating index on expression (func(timestamp)) takes 5 seconds
> 2. creating check constraint on the same expression takes 10 seconds
> 3. adding partition table based on the same expression without check expression takes 20 seconds (this has been resolved by answer from David Rowley)

Hmm ...

> Is it possible to use indices to create check expressions?

No.

> Why is 2. twice as long as 1.?

Good question. Could you provide a concrete test case?

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Boris Sagadin 2018-10-23 05:28:27 Re: Postgres 10, slave not catching up with master
Previous Message Dinko Papak 2018-10-22 17:55:56 Are indices used for creating check constraints?