Unix Technical Forum

Re: Postgres Optimizer is not smart enough?

This is a discussion on Re: Postgres Optimizer is not smart enough? within the Pgsql Performance forums, part of the PostgreSQL category; --> Tom Lane wrote: > Mark Kirkwood <markir@coretech.co.nz> writes: > the costs of paths using these indexes are >>quite similar, ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql Performance

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-18-2008, 11:52 AM
Mark Kirkwood
 
Posts: n/a
Default Re: Postgres Optimizer is not smart enough?

Tom Lane wrote:
> Mark Kirkwood <markir@coretech.co.nz> writes:
> the costs of paths using these indexes are
>>quite similar, so are quite sensitive to (some) parameter values.

>
>
> They'll be exactly the same, actually, as long as the thing predicts
> exactly one row retrieved. So it's quasi-random which plan you get.
>
> btcostestimate needs to be improved to understand that in multicolumn
> index searches with inequality conditions, we may have to scan through
> tuples that don't meet all the qualifications. It's not accounting for
> that cost at the moment, which is why the estimates are the same.
>

I see some small differences in the numbers - I am thinking that these
are due to the calculations etc in cost_index(). e.g:

create_index_paths : index oid 12616389 (test_id2)
cost_index : cost=2.839112 (startup_cost=0.000000 run_cost=2.839112)
: tuples=1.000000 cpu_per_tuple=0.017500
: selectivity=0.000002
: run_index_tot_cost=2.003500 run_io_cost=0.818112)

create_index_paths : index oid 12616388 (test_id1)
cost_index : cost=2.933462 (startup_cost=0.002500 run_cost=2.930962)
: tuples=1.000000 cpu_per_tuple=0.010000
: selectivity=0.000002
: run_index_tot_cost=2.008500 run_io_cost=0.912462


Where:

run_index_tot_cost=indexTotalCost - indexStartupCost;
run_io_cost=max_IO_cost + csquared * (min_IO_cost - max_IO_cost)
selectivity=indexSelectivity

Hmmm ... so it's only the selectivity that is the same (sourced from
index->amcostestimate which I am guessing points to btcostestimate), is
that correct?

cheers

Mark



---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:20 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com