pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: armand pirvu <armand.pirvu@gmail.com>
To: Paul Jungwirth <pj@illuminatedcomputing.com>
Cc: hmidi slim <hmidi.slim2@gmail.com>
Cc: pgsql-general@postgresql.org <pgsql-general@postgresql.org>
Subject: Re: Proposition for better performance
Date: Tue, 27 Mar 2018 16:55:30 -0500
Message-ID: <EA86E98A-0C7E-47C4-9B51-AD5AECB89165@gmail.com> (raw)
In-Reply-To: <eda6182e-d027-7394-896c-d9ba0da89e4c@illuminatedcomputing.com>
References: <CAMsqVxs8xwxH+f40nUNj+5L9Mo9+9z+xsjFxS0k+ajgG=qOz4Q@mail.gmail.com>
	<2e436152-eda0-d67d-4b20-90da0db4a049@illuminatedcomputing.com>
	<CAMsqVxtRD5dCVL3o_eCWNdwo4igQCzjMgXTdD+sDVD8AHHkgDg@mail.gmail.com>
	<834d8a70-386d-7101-f846-ae572140af92@illuminatedcomputing.com>
	<CAMsqVxu2jFANWNDnFRUnM76NS70_u+VrwhmPOiK9U97FK9sm8w@mail.gmail.com>
	<CAMsqVxtg-qZizp==Y3hO-Js7buHMqZJj8MiuYuvUUVoJHo+YOg@mail.gmail.com>
	<072ceb55-6b57-7f9d-78a7-308a03bedc55@illuminatedcomputing.com>
	<CAMsqVxtN5qZ--UuTSjsE0BaP-rGcO0_g20xE+mjqZfUd3VHztg@mail.gmail.com>
	<eda6182e-d027-7394-896c-d9ba0da89e4c@illuminatedcomputing.com>


> On Mar 27, 2018, at 4:25 PM, Paul Jungwirth <pj@illuminatedcomputing.com> wrote:
> 
> 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.
> 
> Sorry, I don't think this is enough information to suggest anything.
> 
> -- 
> Paul              ~{:-)
> pj@illuminatedcomputing.com
> 

I took the case prsented and ran in a sandbox and 

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=1156.67..46856.67 rows=75000 width=44) (actual time=5413.792..11367.379 rows=15000000 loops
=1)
   Recheck Cond: (during @> '[2018-02-01,2018-04-01)'::daterange)
   Heap Blocks: exact=110295
   ->  Bitmap Index Scan on idx_time  (cost=0.00..1137.92 rows=75000 width=0) (actual time=5325.844..5325.844 rows=15000000 loops=1)
         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 
 Seq Scan on product_availabilities  (cost=0.00..242647.91 rows=15000033 width=26) (actual time=0.034..7207.697 rows=15000000 loops=1)
   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 <f.sql > /dev/null
real	2m39.767s
user	1m45.576s
sys	0m12.324s


Not sure if that confirms the OP’s 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


— Armand










view thread (10+ messages)

Message-ID: <EA86E98A-0C7E-47C4-9B51-AD5AECB89165@gmail.com>
Permalink:  ../EA86E98A-0C7E-47C4-9B51-AD5AECB89165@gmail.com/
Also on:    postgresql.org/message-id/EA86E98A-0C7E-47C4-9B51-AD5AECB89165@gmail.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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: armand.pirvu@gmail.com, pj@illuminatedcomputing.com, hmidi.slim2@gmail.com
  Subject: Re: Proposition for better performance
  In-Reply-To: <EA86E98A-0C7E-47C4-9B51-AD5AECB89165@gmail.com>
  References: <CAMsqVxs8xwxH+f40nUNj+5L9Mo9+9z+xsjFxS0k+ajgG=qOz4Q@mail.gmail.com> <2e436152-eda0-d67d-4b20-90da0db4a049@illuminatedcomputing.com> <CAMsqVxtRD5dCVL3o_eCWNdwo4igQCzjMgXTdD+sDVD8AHHkgDg@mail.gmail.com> <834d8a70-386d-7101-f846-ae572140af92@illuminatedcomputing.com> <CAMsqVxu2jFANWNDnFRUnM76NS70_u+VrwhmPOiK9U97FK9sm8w@mail.gmail.com> <CAMsqVxtg-qZizp==Y3hO-Js7buHMqZJj8MiuYuvUUVoJHo+YOg@mail.gmail.com> <072ceb55-6b57-7f9d-78a7-308a03bedc55@illuminatedcomputing.com> <CAMsqVxtN5qZ--UuTSjsE0BaP-rGcO0_g20xE+mjqZfUd3VHztg@mail.gmail.com> <eda6182e-d027-7394-896c-d9ba0da89e4c@illuminatedcomputing.com> <EA86E98A-0C7E-47C4-9B51-AD5AECB89165@gmail.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