Re: Bad query plan with high-cardinality column

Поиск
Список
Период
Сортировка
От Kevin Grittner
Тема Re: Bad query plan with high-cardinality column
Дата
Msg-id 1361571474.31440.YahooMailNeo@web162901.mail.bf1.yahoo.com
обсуждение исходный текст
Ответ на Re: Bad query plan with high-cardinality column  (Alexander Staubo <alex@bengler.no>)
Список pgsql-performance
Alexander Staubo <alex@bengler.no> wrote:
> On Friday, February 22, 2013 at 21:47 , Kevin Grittner wrote:

>> In my experience these problems come largely from the planner
>> not knowing the cost of dealing with each tuple. I see a lot
>> less of this if I raise cpu_tuple_cost to something in the 0.03
>> to 0.05 range.
>
> Is this something I can just frob a bit without worrying about it
> adversely impacting database performance across the board, or
> should I be very careful and do lots of testing on a staging box
> first?

If possible, I would recommend trying it with the old indexes and
seeing whether it causes it to choose the better plan.  (Of course,
you're not going to beat the plan you get with the two-column index
for this query, but it might help it better cost the other
alternatives, which would be a clue that it makes your overall
costing model more accurate and would have a more general benefit.)
You can play with settings like this in a single session without
affecting any other sessions.

I always recommend testing a change like this in staging and
closely monitoring after deploying to production, to confirm the
overall benefit and look for any odd cases which might suffer a
performance regression.  For this particular change, I have never
seen a negative effect, but I'm sure that it's possible to have a
scenario where it isn't helpful.

Personally, I have changed this setting many times and have often
noted that 0.02 was not enough to cause choice of an optimal plan,
0.03 was always enough to do it if adjusting this setting was going
to help at all, and boosting it to 0.05 never caused further plan
changes in the cases I tested.  I have never seen such increases
cause less optimal plan choice.

If you try this, please post your results.

--
Kevin Grittner
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


В списке pgsql-performance по дате отправления:

Предыдущее
От: Alexander Staubo
Дата:
Сообщение: Re: Bad query plan with high-cardinality column
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Bad query plan with high-cardinality column