From: | Justin Pryzby <pryzby(at)telsasoft(dot)com> |
---|---|
To: | Glenn Pierce <glennpierce(at)gmail(dot)com> |
Cc: | pgsql-performance(at)lists(dot)postgresql(dot)org |
Subject: | Re: Slow query on partitioned table. |
Date: | 2018-03-27 21:00:32 |
Message-ID: | 20180327210032.GW28454@telsasoft.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
Re-added -performance.
On Tue, Mar 27, 2018 at 05:13:25PM +0100, Glenn Pierce wrote:
> Damn as I was playing with the indexes I must have deleted the constraints :(
> Question if I have a constraint like
>
> ALTER TABLE sensor_values_2007q1
> ADD CONSTRAINT sensor_values_2007q1_sensor_id_timestamp_constraint
> UNIQUE (sensor_id, ts);
>
> will that be used like an index or do I need to add a separate index ?
Yes:
https://www.postgresql.org/docs/current/static/ddl-constraints.html
|Adding a unique constraint will automatically create a unique B-tree index on
the column or group of columns listed in the constraint
https://www.postgresql.org/docs/current/static/indexes-unique.html
|PostgreSQL automatically creates a unique index when a unique constraint or
|primary key is defined for a table. The index ... is the mechanism that
|enforces the constraint.
Justin
From | Date | Subject | |
---|---|---|---|
Next Message | Merlin Moncure | 2018-04-05 14:18:42 | Re: functions: VOLATILE performs better than STABLE |
Previous Message | Justin Pryzby | 2018-03-27 14:43:15 | Re: Slow query on partitioned table. |