Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aqPwI-0003mJ-L9 for pgsql-performance@arkaria.postgresql.org; Wed, 13 Apr 2016 18:54:58 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1aqPwI-0005zu-7b for pgsql-performance@arkaria.postgresql.org; Wed, 13 Apr 2016 18:54:58 +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.84_2) (envelope-from ) id 1aqPwH-0005zb-IH for pgsql-performance@postgresql.org; Wed, 13 Apr 2016 18:54:57 +0000 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1aqPwE-0002nC-OK for pgsql-performance@postgresql.org; Wed, 13 Apr 2016 18:54:56 +0000 Received: by mail-wm0-x244.google.com with SMTP id l6so16588654wml.3 for ; Wed, 13 Apr 2016 11:54:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=blFtzOUm2uNRgg6zzGBUY7mptTFJAv+OHZGNk9V1ACU=; b=ZnJ6W01zgJOmXsY8ZT6nxw5/YwjBJkEIWlzRDL4uf5NeTxgDfnjgMx+v7iERIuVwLQ er15izf4xZlAvwwb5eldLtNgIjc7LmGiq9ESgHZMq09VVYi2wRGPUcnyJ/OBZEQazg/a Njl/uoiKnA+cex477YUAoOR6dLF9C2XvTiZto3vUu4T2c1/JD34ntuUcwdPFkTS/MFzU TATp7Z1vVUYevzdlIJIRF57VVR+S8rl3kg1+uON6CWm31v8WTNzvJOK7MW9JdCM9WdKM Udo9Ai6VTxaYoelrRkdUZpzjX1ry6y7jENuicCAQewh1noH5zsFggcWWId1/cp/NzlLE NcAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=blFtzOUm2uNRgg6zzGBUY7mptTFJAv+OHZGNk9V1ACU=; b=kzWgCRLvQDIqz5zKT9ELytWyMGWxPL8+earqS4VvnKs2gcGjAA4NLe+QU0ivZpsYMK 7VCcHrV2DSQJTvENpP7sidW84G0u7OWCyhZA/BOJh40WeC/DhPFvmY/HbDz7FKDUVL2W bcyL+L/Y2R1wUOYdhFMhVQAjVh1APlA+UQmIslof3SwRd5FeagNdjUf1VLPMBetX2iA9 4PwPsympTZzZgRDRJiny2B/LvPY0wT1+SafPkwF4dIJbB/9Mlnd2RdTFMqUwXHxIkzB2 p9yh3CG7HctbIrpJmDzWLtP4TSl+hRuykQmp61fHRa3sj3N45pJVRfD+bQYRmZ6ap1mh H6+Q== X-Gm-Message-State: AOPr4FXpXSKUvuGf36f8JuMpH8SZz0uCiv6uS+kW08aVFY1qKQe/w81+f5r/hDfVwVbfAQ== X-Received: by 10.194.90.229 with SMTP id bz5mr12331359wjb.143.1460573692989; Wed, 13 Apr 2016 11:54:52 -0700 (PDT) Received: from [192.168.1.2] ([93.85.33.102]) by smtp.gmail.com with ESMTPSA id l124sm2590530wmf.11.2016.04.13.11.54.51 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 13 Apr 2016 11:54:52 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Subject: Re: Slow update on column that is part of exclusion constraint From: Evgeniy Shishkin In-Reply-To: Date: Wed, 13 Apr 2016 21:54:45 +0300 Cc: pgsql-performance@postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: <5C918770-5BC7-43E2-90B1-9A90174370F6@gmail.com> References: To: Adam Brusselback X-Mailer: Apple Mail (2.3124) X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org > On 13 Apr 2016, at 20:14, Adam Brusselback wr= ote: >=20 > Sorry, brain stopped working and I forgot to include the normal info. >=20 > Postgres version: 9.5.1 > Hardware: 2 core, 4gb Digital Ocean virtual server > OS: Debian=20 >=20 > explain analyze for an example update: > 'Update on price_generated (cost=3D32.45..644.83 rows=3D1 width=3D157) (= actual time=3D29329.614..29329.614 rows=3D0 loops=3D1)' > ' -> Nested Loop (cost=3D32.45..644.83 rows=3D1 width=3D157) (actual t= ime=3D29329.608..29329.608 rows=3D0 loops=3D1)' > ' -> HashAggregate (cost=3D32.04..34.35 rows=3D231 width=3D52) (= actual time=3D1.137..2.090 rows=3D231 loops=3D1)' > ' Group Key: pti.product_id, pti.company_id, pti.date_range' > ' -> Seq Scan on _prices_to_insert pti (cost=3D0.00..30.31= rows=3D231 width=3D52) (actual time=3D0.060..0.678 rows=3D231 loops=3D1)' > ' -> Index Scan using price_generated_company_product_date_active= _excl on price_generated (cost=3D0.41..2.63 rows=3D1 width=3D151) (actual = time=3D126.949..126.949 rows=3D0 loops=3D231)' > ' Index Cond: (date_range =3D pti.date_range)' > ' Filter: ((upper(active_range) IS NULL) AND (pti.product_id= =3D product_id) AND (pti.company_id =3D company_id))' > ' Rows Removed by Filter: 29460' > 'Planning time: 3.134 ms' > 'Execution time: 29406.717 ms' Well, you see execution time of 30 seconds because there are 231 index look= ups, each taking 126 ms. And that lookup is slow because of Filter: ((upper(active_range) IS NULL) AND (pti.product_id =3D product_id) = AND (pti.company_id =3D company_id))' Can you provide self-containing example of update? I don't see there (upper(active_range) IS NULL condition is coming from. --=20 Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance