pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Pavel Tavoda <pavel.tavoda@gmail.com>
To: Pavel Stehule <pavel.stehule@gmail.com>
Cc: pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
Subject: Re: BUG #14729: Between operator is slow when same value used for low and high margin
Date: Mon, 3 Jul 2017 16:39:01 +0200
Message-ID: <CAMRASbLR2-0Q3UtRK2v6O2A5_cUkA8+9GUak7eAwN9EnebtRcQ@mail.gmail.com> (raw)
In-Reply-To: <CAFj8pRC85hYM=N_d-jxsq9hjMh0FPcsjjnTb3uLpTh3jM8JQsw@mail.gmail.com>
References: <20170703100923.1448.48433@wrigleys.postgresql.org>
	<CAFj8pRC85hYM=N_d-jxsq9hjMh0FPcsjjnTb3uLpTh3jM8JQsw@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

Hi Pavel, results down in text.

On Mon, Jul 3, 2017 at 4:22 PM, Pavel Stehule <pavel.stehule@gmail.com>
wrote:

> Hi
>
> 2017-07-03 12:09 GMT+02:00 <pavel.tavoda@gmail.com>:
>
>> SELECT count(*) FROM contractportfolio cp JOIN contract co ON cp.contract
>> =
>> co.id WHERE validfor between '2017-05-30' AND '2017-05-31';
>> Time: 0.473
>>
> Aggregate  (cost=110320.00..110320.01 rows=1 width=0) (actual
time=520.304..520.304 rows=1 loops=1)
  ->  Hash Join  (cost=426.27..110244.02 rows=30393 width=0) (actual
time=5.852..509.223 rows=40844 loops=1)
        Hash Cond: (cp.contract = co.id)
        ->  Seq Scan on contractportfolio cp  (cost=0.00..109171.90
rows=30393 width=8) (actual time=0.007..471.669 rows=40844 loops=1)
              Filter: ((validfor >= '2017-05-30'::date) AND (validfor <=
'2017-05-31'::date))
              Rows Removed by Filter: 2946433
        ->  Hash  (cost=336.12..336.12 rows=7212 width=8) (actual
time=5.833..5.833 rows=7198 loops=1)
              Buckets: 1024  Batches: 1  Memory Usage: 197kB
              ->  Seq Scan on contract co  (cost=0.00..336.12 rows=7212
width=8) (actual time=0.006..2.856 rows=7198 loops=1)
Planning time: 0.333 ms
Execution time: 520.343 ms




> SELECT count(*) FROM contractportfolio cp JOIN contract co ON cp.contract =
>> co.id WHERE validfor between '2017-05-31' AND '2017-05-31';
>> Time: 19.172
>>
> Aggregate  (cost=109598.17..109598.18 rows=1 width=0) (actual
time=87769.576..87769.577 rows=1 loops=1)
  ->  Nested Loop  (cost=0.00..109598.16 rows=1 width=0) (actual
time=1.949..87759.415 rows=20426 loops=1)
        Join Filter: (cp.contract = co.id)
        Rows Removed by Join Filter: 147005922
        ->  Seq Scan on contractportfolio cp  (cost=0.00..109171.90 rows=1
width=8) (actual time=0.009..486.918 rows=20426 loops=1)
              Filter: ((validfor >= '2017-05-31'::date) AND (validfor <=
'2017-05-31'::date))
              Rows Removed by Filter: 2966851
        ->  Seq Scan on contract co  (cost=0.00..336.12 rows=7212 width=8)
(actual time=0.001..2.046 rows=7198 loops=20426)
Planning time: 0.319 ms
Execution time: 87769.621 ms

STUNNING!!!!


>
>> SELECT count(*) FROM contractportfolio cp JOIN contract co ON cp.contract
>> =
>> co.id WHERE validfor = '2017-05-31';
>> Time: 0.467
>>
> Aggregate  (cost=102402.86..102402.87 rows=1 width=0) (actual
time=492.645..492.646 rows=1 loops=1)
  ->  Hash Join  (cost=426.27..102352.37 rows=20197 width=0) (actual
time=5.873..486.873 rows=20426 loops=1)
        Hash Cond: (cp.contract = co.id)
        ->  Seq Scan on contractportfolio cp  (cost=0.00..101496.91
rows=20197 width=8) (actual time=0.009..463.063 rows=20426 loops=1)
              Filter: (validfor = '2017-05-31'::date)
              Rows Removed by Filter: 2966851
        ->  Hash  (cost=336.12..336.12 rows=7212 width=8) (actual
time=5.856..5.856 rows=7198 loops=1)
              Buckets: 1024  Batches: 1  Memory Usage: 197kB
              ->  Seq Scan on contract co  (cost=0.00..336.12 rows=7212
width=8) (actual time=0.005..2.835 rows=7198 loops=1)
Planning time: 0.325 ms
Execution time: 492.686 ms

view thread (6+ messages)  latest in thread

Message-ID: <CAMRASbLR2-0Q3UtRK2v6O2A5_cUkA8+9GUak7eAwN9EnebtRcQ@mail.gmail.com>
Permalink:  ../CAMRASbLR2-0Q3UtRK2v6O2A5_cUkA8+9GUak7eAwN9EnebtRcQ@mail.gmail.com/
Also on:    postgresql.org/message-id/CAMRASbLR2-0Q3UtRK2v6O2A5_cUkA8+9GUak7eAwN9EnebtRcQ@mail.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-bugs@postgresql.org
  Cc: pavel.tavoda@gmail.com, pavel.stehule@gmail.com
  Subject: Re: BUG #14729: Between operator is slow when same value used for low and high margin
  In-Reply-To: <CAMRASbLR2-0Q3UtRK2v6O2A5_cUkA8+9GUak7eAwN9EnebtRcQ@mail.gmail.com>
  References: <20170703100923.1448.48433@wrigleys.postgresql.org> <CAFj8pRC85hYM=N_d-jxsq9hjMh0FPcsjjnTb3uLpTh3jM8JQsw@mail.gmail.com> <CAMRASbLR2-0Q3UtRK2v6O2A5_cUkA8+9GUak7eAwN9EnebtRcQ@mail.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