From: Gary Doades <gpd@gpdnet.co.uk>
To: pgsql-performance@postgresql.org
Subject: Re: Optimizing a request
Date: Tue, 31 Aug 2004 20:21:49 +0100
Message-ID: <4134DDDD.428.4AF67CC@localhost> (raw)
In-Reply-To: <4b09a0c0408311159fa91802@mail.gmail.com>
On 31 Aug 2004 at 20:59, Jean-Max Reymond wrote:
> hi,
>
> I want to optimize the following request and avoid the seq scan on the
> table article (10000000 rows).
>
> explain SELECT art_id, art_titre, art_texte, rub_titre
> FROM article inner join rubrique on article.rub_id = rubrique.rub_id
> where rub_parent = 8;
>
> Hash Join (cost=8.27..265637.59 rows=25 width=130)
> Hash Cond: ("outer".rub_id = "inner".rub_id)
> -> Seq Scan on article (cost=0.00..215629.00 rows=10000000 width=108)
> -> Hash (cost=8.26..8.26 rows=3 width=22)
> -> Index Scan using rubrique_parent on rubrique
> (cost=0.00..8.26 rows=3 width=22)
> Index Cond: (rub_parent = 8)
>
>
> thanks for your answers,
>
> --
Have you run ANALYZE on this database after creating the indexes or
loading the data?
What percentage of rows in the "article" table are likely to match the
keys selected from the "rubrique" table?
If it is likely to fetch a high proportion of the rows from article then it
may be best that a seq scan is performed.
What are your non-default postgresql.conf settings? It may be better to
increase the default_statistics_target (to say 100 to
200) before running ANALYZE and then re-run the
query.
Cheers,
Gary.
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 using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: gpd@gpdnet.co.uk
Subject: Re: Optimizing a request
In-Reply-To: <4134DDDD.428.4AF67CC@localhost>
* 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