From: Willem Leenen <willem_leenen@hotmail.com>
To: vyegorov@gmail.com
Cc: p.jimenez@ismsolar.com
Cc: pgsql-performance@postgresql.org
Subject: Re: help with too slow query
Date: Tue, 6 Nov 2012 15:12:27 +0000
Message-ID: <DUB104-W15E74595B06FB1B6281F08F6B0@phx.gbl> (raw)
In-Reply-To: <CAGnEbohN9AAErADpi6q438n1oKLaQb_UhFuOGPPXnoaGrdeYDA@mail.gmail.com>
References: <5093B900.7020206@ismsolar.com>
<CAGnEbog1qNRhYjtMrfX=DTJcKdyQKYE7iH-pU7KAAdeYgLQaHg@mail.gmail.com>
<5098D323.40706@ismsolar.com>
<CAGnEbojPp296-05nij8dbofcy2i2WK9cMnB83B2y66KFZggGbA@mail.gmail.com>
<DUB104-W5416A60BE516D5A92A16E08F6B0@phx.gbl>
<CAGnEbohN9AAErADpi6q438n1oKLaQb_UhFuOGPPXnoaGrdeYDA@mail.gmail.com>
@Victor,
Spasibo for the information, seems valid to me.
Regards,
Willem Leenen
> Date: Tue, 6 Nov 2012 16:52:01 +0200
> Subject: Re: [PERFORM] help with too slow query
> From: vyegorov@gmail.com
> To: willem_leenen@hotmail.com
> CC: p.jimenez@ismsolar.com; pgsql-performance@postgresql.org
>
> 2012/11/6 Willem Leenen <willem_leenen@hotmail.com>:
> > @Victor,
> >
> > Is the reason of the wrong cardinality estimations of the join indeed due to
> > wrong statistics? I thought that the full table scan was due to the index on
> > the timefield couldn't be used with this predicate:
> >
> > time_stamp > date_trunc('month', current_date - interval '11 months')
> >
> > It seems to me that a deterministic FBI should be made of this, deviding the
> > records into month chuncks. Sort of a patch in stead of using partitions.
> > But I'm new to Postgresql, so correct me if i'm wrong,
>
> In 8.0, default_statistics_target=10, which means 1e8 rows big table
> will get only 10 ranges
> for the histograms, a bit too low to get a proper guess on the data
> distribution. I would also
> have increased default_statistics_target instance-wide, up to 50 at least.
>
> PostgreSQL can use the index as it is and apply a filter afterwards
> for each record emited by
> the index scan. Very rough estimate shows, that there'll be round 4.2k
> rows for each id_signal
> in the ism_floatvalues tables. So index scan looks valid here with the
> given setup.
>
> With increased statistics target for the column I hope optimizer will
> do a more precise estimate on
> the column selectivity and will prefer to do a NestedLoop join between
> ism_signal and ism_floatvalues tables.
>
> I haven't considered the FBI though.
>
> I hope I'm not mistaken here, waiting for the OP to provide more input.
>
>
> --
> Victor Y. Yegorov
>
>
> --
> Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-performance =
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-performance@postgresql.org
Cc: willem_leenen@hotmail.com, vyegorov@gmail.com, p.jimenez@ismsolar.com
Subject: Re: help with too slow query
In-Reply-To: <DUB104-W15E74595B06FB1B6281F08F6B0@phx.gbl>
References: <5093B900.7020206@ismsolar.com> <CAGnEbog1qNRhYjtMrfX=DTJcKdyQKYE7iH-pU7KAAdeYgLQaHg@mail.gmail.com> <5098D323.40706@ismsolar.com> <CAGnEbojPp296-05nij8dbofcy2i2WK9cMnB83B2y66KFZggGbA@mail.gmail.com> <DUB104-W5416A60BE516D5A92A16E08F6B0@phx.gbl> <CAGnEbohN9AAErADpi6q438n1oKLaQb_UhFuOGPPXnoaGrdeYDA@mail.gmail.com> <DUB104-W15E74595B06FB1B6281F08F6B0@phx.gbl>
* 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