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 1f0wZd-00006H-Sa for pgsql-general@arkaria.postgresql.org; Tue, 27 Mar 2018 21:56:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f0wZc-0000eV-19 for pgsql-general@arkaria.postgresql.org; Tue, 27 Mar 2018 21:56:08 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f0wZb-0000eL-NH for pgsql-general@lists.postgresql.org; Tue, 27 Mar 2018 21:56:07 +0000 Received: from mail-qk0-x242.google.com ([2607:f8b0:400d:c09::242]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1f0wZX-0008W8-WC for pgsql-general@postgresql.org; Tue, 27 Mar 2018 21:56:06 +0000 Received: by mail-qk0-x242.google.com with SMTP id o184so418508qkd.13 for ; Tue, 27 Mar 2018 14:56:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=eaLpDccZ1I5SxbB38GNngT1a7Mf1fIHPWgN6iXTuCx4=; b=FWhUrUkZ4/0cuUtxLkY9aivHAEmtFbpdEWFU8xQiuHbu1vg+ONKdWaQ+WJx+H+o8+d LwvMTa3L7s47gLCf18pMGY4UK++0o2G+weQZn4bqtmo5AJTZXqni3YC0VFrTlxK5USmN 0i/ZRWFfW9LonSsh3MLO8CBZvqc/BE8dXTh/EnUelF/RzHC2zILd5NjIWFYpI3pUPixj dWdDW9TCn99XiZ2tQPFStmWb72he5EPWWcWgJezv9ormkCqOnHgcuKrtnDx8JzNaRFTQ mGManjmYaaf29egtdy/dL63f1cCmTl8oYBRh37CIikWVeweljHjEbnD7kK2Gdpdom2GI bCEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=eaLpDccZ1I5SxbB38GNngT1a7Mf1fIHPWgN6iXTuCx4=; b=HREcdDRE5ExVC39RSfaqbRloj6hcdFvmuejzm51c20RYofhYNoNFwMaKMuhbqKTgop rKWhWq69ZDd7+Fo5hKu2j4fKDylMitkyvoqdys77/BVf8OVmIBkl/W+B3hseHSTE0/Ue JHH1FI/Q6KwdLn8PArjrQYvJDmNyKZjGc39DwMI07+KVUhlxmRmo6DBghwRav+2tJPPs 8bN8erifkxrQ5MurFQ8Xa8C02ciglrO9WQnpNxqv46CYxStpumjLbe6XT3hF1acvd4tm ulXGtAps1BetifEYvrpplr+BxEux5d5st+jnubA5fNqg2t4KfnY74WF37/oKdSI9moKJ lOOA== X-Gm-Message-State: ALQs6tA8bEnSePeI79bnMgc9irKt6qaSi7uRWYvqL2apl5iRV/W8Urrn 05Drwef5ZaJx7PsbRWlbr3E= X-Google-Smtp-Source: AIpwx48PONABvYxO9UYBvvuH1hkrLCneAKdxifR1NrzxCodUAR/t1BrQi4k8xwzjjHdPd4t3QgPjEw== X-Received: by 10.55.20.22 with SMTP id e22mr1679103qkh.12.1522187762236; Tue, 27 Mar 2018 14:56:02 -0700 (PDT) Received: from ?IPv6:2605:a601:2062:d00:edc6:3403:5c7a:2508? ([2605:a601:2062:d00:edc6:3403:5c7a:2508]) by smtp.gmail.com with ESMTPSA id r4sm1616573qki.0.2018.03.27.14.56.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Mar 2018 14:56:01 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: Proposition for better performance From: armand pirvu In-Reply-To: Date: Tue, 27 Mar 2018 16:55:30 -0500 Cc: hmidi slim , "pgsql-general@postgresql.org" Content-Transfer-Encoding: quoted-printable Message-Id: References: <2e436152-eda0-d67d-4b20-90da0db4a049@illuminatedcomputing.com> <834d8a70-386d-7101-f846-ae572140af92@illuminatedcomputing.com> <072ceb55-6b57-7f9d-78a7-308a03bedc55@illuminatedcomputing.com> To: Paul Jungwirth X-Mailer: Apple Mail (2.3273) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > On Mar 27, 2018, at 4:25 PM, Paul Jungwirth = wrote: >=20 > On 03/27/2018 11:42 AM, hmidi slim wrote: >> This is the message that I got: >> Successfully run. Total query runtime: 2 min. >> 15000000 rows affected. >=20 > Sorry, I don't think this is enough information to suggest anything. >=20 > --=20 > Paul ~{:-) > pj@illuminatedcomputing.com >=20 I took the case prsented and ran in a sandbox and=20 UPDATE 15000000 explain analyze SELECT product_id, start_date, end_date, during FROM product_availabilities WHERE during @> daterange('2018-02-01', '2018-04-01') Bitmap Heap Scan on product_availabilities (cost=3D1156.67..46856.67 = rows=3D75000 width=3D44) (actual time=3D5413.792..11367.379 = rows=3D15000000 loops =3D1) Recheck Cond: (during @> '[2018-02-01,2018-04-01)'::daterange) Heap Blocks: exact=3D110295 -> Bitmap Index Scan on idx_time (cost=3D0.00..1137.92 rows=3D75000 = width=3D0) (actual time=3D5325.844..5325.844 rows=3D15000000 loops=3D1) Index Cond: (during @> '[2018-02-01,2018-04-01)'::daterange) Planning time: 0.145 ms Execution time: 14055.666 ms (7 rows) But considering the update (I did not check bloating or anything but still) vacuum full product_availabilities; analyze product_availabilities; The plan changes to=20 Seq Scan on product_availabilities (cost=3D0.00..242647.91 = rows=3D15000033 width=3D26) (actual time=3D0.034..7207.697 rows=3D15000000= loops=3D1) Filter: (during @> '[2018-02-01,2018-04-01)'::daterange) Planning time: 6.701 ms Execution time: 9238.285 ms And the runtime does get in the two minutes time psql -U csidba -d armandp /dev/null real 2m39.767s user 1m45.576s sys 0m12.324s Not sure if that confirms the OP=E2=80=99s findings but to me a first = question would be if the fact that the execution time reported by = epxlain analyze does not seem to be even close to the actual run time is = expected or not BTW I was the postgres version reported ? I ran the presented case on = 9.5.8 =E2=80=94 Armand