pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Justin Pryzby <pryzby@telsasoft.com>
To: Glenn Pierce <glennpierce@gmail.com>
Cc: pgsql-performance@lists.postgresql.org
Subject: Re: Slow query on partitioned table.
Date: Tue, 27 Mar 2018 16:00:32 -0500
Message-ID: <20180327210032.GW28454@telsasoft.com> (raw)
In-Reply-To: <CAM5ipV8Ag6Ft4TBGYs4VGZWAiWoatg91PUw3+3vQehwsLWfOog@mail.gmail.com>
References: <CAM5ipV_iX11SW4EveqauQ=OXcyY5x9_WpM28hWZ-xjyyV=yJbA@mail.gmail.com>
	<20180327144315.GO28454@telsasoft.com>
	<CAM5ipV8Ag6Ft4TBGYs4VGZWAiWoatg91PUw3+3vQehwsLWfOog@mail.gmail.com>

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




view thread (3+ messages)

Message-ID: <20180327210032.GW28454@telsasoft.com>
Permalink:  ../20180327210032.GW28454@telsasoft.com/
Also on:    postgresql.org/message-id/20180327210032.GW28454@telsasoft.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: pryzby@telsasoft.com, glennpierce@gmail.com, pgsql-performance@lists.postgresql.org
  Subject: Re: Slow query on partitioned table.
  In-Reply-To: <20180327210032.GW28454@telsasoft.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox