Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f0vhx-0005Ty-GP for pgsql-performance@arkaria.postgresql.org; Tue, 27 Mar 2018 21:00:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f0vhw-0006Xd-88 for pgsql-performance@arkaria.postgresql.org; Tue, 27 Mar 2018 21:00:40 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f0vhv-0006XS-P6 for pgsql-performance@lists.postgresql.org; Tue, 27 Mar 2018 21:00:40 +0000 Received: from mail-it0-x241.google.com ([2607:f8b0:4001:c0b::241]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1f0vhs-0000Bf-AC for pgsql-performance@lists.postgresql.org; Tue, 27 Mar 2018 21:00:38 +0000 Received: by mail-it0-x241.google.com with SMTP id 142-v6so962835itl.5 for ; Tue, 27 Mar 2018 14:00:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=V5LS63fCa5wWjKuX12L/Y4EVAay5/Auc/5sVnIuDx8c=; b=WewOSnm6Ts+/hyiwfo50EykIbeK2R+HdSq+MtG6Nl4tePdr613m7kdQdlFAZ8C4PIP 3R6O6VvjfXQDGk/7CGsRclMcRCrHuWdipWf72MIBXmAImcJagwylaz+6SyPQ/PzbAQW3 /TXMmtd7HqeTKAUSB0ZVTayCo4V1g3wb78vRldLesj2rvqeoTLrOx1zsH/iqw18oU6qS PGmIxNxI9XwHvGz/zA7kQH0eFX3PD1AFqEd8llvJpcaciz3oY6ovqo+nFFlGxq8ifNzy BFsuQzxmH1eLaS1LQvAULTQQaoio9q0HUSWAjizt+QkMNbDMccihUlqjU2EZfmCOvFba 0mWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=V5LS63fCa5wWjKuX12L/Y4EVAay5/Auc/5sVnIuDx8c=; b=m26ZMUU2Sp5H6oxc7rl4F1vfNTD5DBDN+nLRXk/q+YLT2tDUmdt2jIOzQdZ+5GOXxf lZWl+R7Ra3U5N+w8nOuwicH98KfqRVuLuae9EHjJQ2+0e7FYVj1TssPvJnVq/wgvW3DN aNNPm27vgdyUuRq7UEQeCzQy6mItub6b5RXn+lu9B7XZb5xjSpNnpka1UON07gALtv6g FsbARnnz2ORXErZ+cBqKBNH9XF9rB146lXSs5VLHBZ/Bggjr0irok9agp/6oFv7aQNvv 4fG+4yk8fsvJGuYgJyZsR0tIa3hR1ICjHbryNptSrOvnXVDOcA5xbmKWkwzWCcGExj6U V8bg== X-Gm-Message-State: AElRT7Gji1hews2DU/0Cqg55iOjMVupc5xCvd9LVh5clyPK9/WXinZn5 9z1zCip028FuqnxuujV+l2dqvQ== X-Google-Smtp-Source: AIpwx492/twtsmVI6kCYpa9GYSZA1t0IRipyu0HjzYBdTUHzetrXuoqlpbfUc+XNPS+nwWsrHLu88w== X-Received: by 2002:a24:ac07:: with SMTP id s7-v6mr869704ite.116.1522184435064; Tue, 27 Mar 2018 14:00:35 -0700 (PDT) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id v3-v6sm1608885itb.42.2018.03.27.14.00.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Mar 2018 14:00:34 -0700 (PDT) Received: by pryzbyj (Postfix, from userid 1000) id D4CFA80105A; Tue, 27 Mar 2018 16:00:32 -0500 (CDT) Date: Tue, 27 Mar 2018 16:00:32 -0500 From: Justin Pryzby To: Glenn Pierce Cc: pgsql-performance@lists.postgresql.org Subject: Re: Slow query on partitioned table. Message-ID: <20180327210032.GW28454@telsasoft.com> References: <20180327144315.GO28454@telsasoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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