costing for arbitrary path

Lists: pgsql-hackers
From: uwcssa <uwcssa(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: costing for arbitrary path
Date: 2007-01-04 03:51:58
Message-ID: f2f562510701031951xb122b05j3742d09bd70df44@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

I wish to estimate the total cost for a given path of a query. This
path is a tree consists of nestloop, hashjoin, mergejoin as internal
nodes with seqscan or idxscan at the leaves.

My approach is to cost the path bottom-up, and invoke the
"cost_nestloop", "cost_merge_join" etc.

The problem is that each join method has some value that seems to
change value each time I cost the SAME path. For example, the
hash-join has "thisbucketsize" varying from time to time. I noticed
this is because the caching the bucket size estimate inside the
RestrictInfo structure. Is there a easy way to cost a give path?


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: uwcssa <uwcssa(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: costing for arbitrary path
Date: 2007-01-04 05:49:03
Message-ID: 12985.1167889743@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

uwcssa <uwcssa(at)gmail(dot)com> writes:
> The problem is that each join method has some value that seems to
> change value each time I cost the SAME path.

There's a bug in your code; but you've not provided nearly enough detail
to identify exactly what it is.

regards, tom lane