Re: Optimizer improvements: to do or not to do?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Joshua Reich <josh(at)root(dot)net>
Cc: Ron Mayer <rm_pg(at)cheapcomplexdevices(dot)com>, Gregory Stark <stark(at)enterprisedb(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Optimizer improvements: to do or not to do?
Date: 2006-09-14 00:55:12
Message-ID: 21824.1158195312@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Joshua Reich <josh(at)root(dot)net> writes:
> I lurk... I don't know if I'm a 'statistics jock', but I may be
> valuable if only I had a better understanding of how the optimizer
> works. I have been following this thread with interest, but could really
> do with a good pointer to background information beyond what I have read
> in the main postgres manual. Does such information exist, and if so,
> where ?

Well, there's the 20000-foot view here:
http://developer.postgresql.org/pgdocs/postgres/planner-optimizer.html
but after that you have to start reading code.

The optimizer README file may be useful:
http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/README
but it goes into a lot of details that probably aren't interesting for
your purposes. Most of the planner is just mechanism associated with
generating different possible plans. The policy that determines which
plan is chosen is the cost-estimation equations, and those are all in
costsize.c and selfuncs.c:
http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/path/costsize.c
http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/adt/selfuncs.c
The division between these two files is a bit historical, but roughly
speaking selfuncs.c knows about the behavior of specific WHERE-clause
operators and index access methods, while costsize.c knows about the
behavior of particular plan types.

I'd like to think that costsize.c is well enough commented that you can
follow it even without any C knowledge, but selfuncs.c may be a bit more
daunting. Still, the comments are pretty extensive, and feel free to
ask questions on pg-hackers.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Mark Dilger 2006-09-14 01:23:11 Re: Fixed length data types issue
Previous Message Bruce Momjian 2006-09-14 00:36:43 Re: Patch attribution and non-ASCII characters