Re: Suboptimal execution plan for simple query

From: "Markus Wollny" <Markus(dot)Wollny(at)computec(dot)de>
To: "Sam Mason" <sam(at)samason(dot)me(dot)uk>,<pgsql-general(at)postgresql(dot)org>
Subject: Re: Suboptimal execution plan for simple query
Date: 2008-11-13 12:56:11
Message-ID: 28011CD60FB1724DBA4442E38277F6260AF9915F@hermes.computec.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi!

Sam Mason wrote:
> You may have some luck with increasing the statistics target on the
> entry_id and last_updated columns and re-ANALYZING the table. Then
> again, the fact that it thinks it's only going to get a single row
> back when it searches for the entity_id suggests that it's all a bit
> confused!

Thank you for that suggestion. Increasing the statistics target on entity_id from the default 10 to 30 and re-analyzing did the trick:

"Limit (cost=340.75..340.75 rows=1 width=12) (actual time=0.084..0.085 rows=1 loops=1)"
" -> Sort (cost=340.75..341.00 rows=103 width=12) (actual time=0.081..0.081 rows=1 loops=1)"
" Sort Key: last_updated"
" -> Index Scan using idx_image_relation_entity_id on image_relation (cost=0.00..337.30 rows=103 width=12) (actual time=0.059..0.065 rows=3 loops=1)"
" Index Cond: (entity_id = 69560)"
"Total runtime: 0.121 ms"

Kind regards

Markus

Computec Media AG
Sitz der Gesellschaft und Registergericht: Fürth (HRB 8818)
Vorstandsmitglieder: Johannes S. Gözalan (Vorsitzender) und Rainer Rosenbusch
Vorsitzender des Aufsichtsrates: Jürg Marquard
Umsatzsteuer-Identifikationsnummer: DE 812 575 276

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2008-11-13 13:04:53 Re: Stored function - send array as parameter to stored function
Previous Message Louis-David Mitterrand 2008-11-13 12:20:38 DBI error when changing views