Re: : Cost calculation for EXPLAIN output

Поиск
Список
Период
Сортировка
От Kevin Grittner
Тема Re: : Cost calculation for EXPLAIN output
Дата
Msg-id 4F461A2D0200002500045ABD@gw.wicourts.gov
обсуждение исходный текст
Ответ на : Cost calculation for EXPLAIN output  (Venkat Balaji <venkat.balaji@verse.in>)
Ответы Re: : Cost calculation for EXPLAIN output
Список pgsql-performance
Venkat Balaji <venkat.balaji@verse.in> wrote:


> The cost is "13.88" to fetch 1 row by scanning an Primary Key
> indexed column.
>
> Isn't the cost for fetching 1 row is too high ?

I don't know, how many index pages will need to be randomly accessed
in addition to the random heap access?  How many dead versions of
the row will need to be visited besides the row which is actually
visible?  How many of these pages are in shared_buffers?  How many
of these pages are in OS cache?

> I am looking for a way to reduce cost as much as possible because
> the query executes 100000+ times a day.

Well, you can reduce the cost all you want by dividing all of the
costing factors in postgresql.conf by the same value, but that won't
affect query run time.  That depends on the query plan which is
chosen.  The cost is just an abstract number used for comparing the
apparent resources needed to run a query through each of the
available plans.  What matters is that the cost factors accurately
reflect the resources used; if not you should adjust them.

If you calculate a ratio between run time and estimated cost, you
should find that it remains relatively constant (like within an
order of magnitude) for various queries.  Since you didn't show
actual run times, we can't tell whether anything need adjustment.

-Kevin

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

Предыдущее
От: Shaun Thomas
Дата:
Сообщение: Re: Very long deletion time on a 200 GB database
Следующее
От: Shaun Thomas
Дата:
Сообщение: Re: : Cost calculation for EXPLAIN output