Re: Query Optimizer makes a poor choice - Mailing list pgsql-general

From Filip Rembiałkowski
Subject Re: Query Optimizer makes a poor choice
Date
Msg-id CAP_rwwkE8pGhGsOXt2LQgE9K9_B4LRaLe7=0pT3ZdRQYeEPixQ@mail.gmail.com
Whole thread Raw
In response to Query Optimizer makes a poor choice  ("Tyler Hains" <thains@profitpointinc.com>)
Responses Re: Query Optimizer makes a poor choice  ("Tyler Hains" <thains@profitpointinc.com>)
List pgsql-general
2011/11/29 Tyler Hains <thains@profitpointinc.com>:
> # explain analyze select * from cards where card_set_id=2850 order by
> card_id limit 1;
>                                                                QUERY PLAN
>
-----------------------------------------------------------------------------------------------------------------------------------------
>  Limit  (cost=0.00..105.19 rows=1 width=40) (actual time=6026.947..6026.948
> rows=1 loops=1)
>    ->  Index Scan using cards_pkey on cards  (cost=0.00..2904875.38
> rows=27616 width=40) (actual time=6026.945..6026.945 rows=1 loops=1)
>          Filter: (card_set_id = 2850)
>  Total runtime: 6026.985 ms

do you have autovacum enabled?

does the plan change when you push stats target for this column?
ALTER TABLE cards ALTER card_set_id SET STATISTICS 500;
ANALYZE cards ( card_set_id );

what happens when you do:
select * from ( select * from cards where card_set_id=2850 ) order by
card_id limit 1
?

pgsql-general by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: stored function data structures - difficulty
Next
From: Filip Rembiałkowski
Date:
Subject: Re: initdb failure on Windows 2003