Re: Slow query on partitioned table. - Mailing list pgsql-performance

From Justin Pryzby
Subject Re: Slow query on partitioned table.
Date
Msg-id 20180327210032.GW28454@telsasoft.com
Whole thread Raw
In response to Slow query on partitioned table.  (Glenn Pierce <glennpierce@gmail.com>)
List 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


pgsql-performance by date:

Previous
From: Justin Pryzby
Date:
Subject: Re: Slow query on partitioned table.
Next
From: Merlin Moncure
Date:
Subject: Re: functions: VOLATILE performs better than STABLE