Where can I find the code for extern OidFunctionCall7?

Started by arthernanover 12 years ago6 messages
#1arthernan
arthernan@hotmail.com

OidFunctionCall7 is called from costsize.c, in function void cost_index. From
the comments, I understand that there is an indirection mechanism here to
allow for different index access methods. Looking at fmgr.h where it is
declared is not clear to me where I would ultimately find the code.

Any pointers will be greatly appreciated

/*
* Call index-access-method-specific code to estimate the processing cost
* for scanning the index, as well as the selectivity of the index (ie,
* the fraction of main-table tuples we will have to retrieve) and its
* correlation to the main-table tuple order.
*/
OidFunctionCall7(index->amcostestimate,
PointerGetDatum(root),
PointerGetDatum(path),
Float8GetDatum(loop_count),
PointerGetDatum(&indexStartupCost),
PointerGetDatum(&indexTotalCost),
PointerGetDatum(&indexSelectivity),
PointerGetDatum(&indexCorrelation));

--
View this message in context: http://postgresql.1045698.n5.nabble.com/Where-can-I-find-the-code-for-extern-OidFunctionCall7-tp5769737.html
Sent from the PostgreSQL - hackers mailing list archive at Nabble.com.

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#2Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: arthernan (#1)
Re: Where can I find the code for extern OidFunctionCall7?

arthernan wrote:

OidFunctionCall7 is called from costsize.c, in function void cost_index. From
the comments, I understand that there is an indirection mechanism here to
allow for different index access methods. Looking at fmgr.h where it is
declared is not clear to me where I would ultimately find the code.

Any pointers will be greatly appreciated

The code you're really looking for is the amcostestimate function of the
AM that the index uses. So if it's a btree you want btcostestimate, for
instance. You can see the AM definitions in the pg_am system catalog
and src/include/catalog/pg_am.h.

/*
* Call index-access-method-specific code to estimate the processing cost
* for scanning the index, as well as the selectivity of the index (ie,
* the fraction of main-table tuples we will have to retrieve) and its
* correlation to the main-table tuple order.
*/
OidFunctionCall7(index->amcostestimate,
PointerGetDatum(root),
PointerGetDatum(path),
Float8GetDatum(loop_count),
PointerGetDatum(&indexStartupCost),
PointerGetDatum(&indexTotalCost),
PointerGetDatum(&indexSelectivity),
PointerGetDatum(&indexCorrelation));

--
�lvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3Robert Haas
robertmhaas@gmail.com
In reply to: arthernan (#1)
Re: Where can I find the code for extern OidFunctionCall7?

On Thu, Sep 5, 2013 at 12:38 PM, arthernan <arthernan@hotmail.com> wrote:

OidFunctionCall7 is called from costsize.c, in function void cost_index. From
the comments, I understand that there is an indirection mechanism here to
allow for different index access methods. Looking at fmgr.h where it is
declared is not clear to me where I would ultimately find the code.

Any pointers will be greatly appreciated

Use 'git grep'. It's a macro defined in fmgr.h.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#4arthernan
arthernan@hotmail.com
In reply to: Robert Haas (#3)
Re: Where can I find the code for extern OidFunctionCall7?

Thank you guys!

--
View this message in context: http://postgresql.1045698.n5.nabble.com/Where-can-I-find-the-code-for-extern-OidFunctionCall7-tp5769737p5769753.html
Sent from the PostgreSQL - hackers mailing list archive at Nabble.com.

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#5arthernan
arthernan@hotmail.com
In reply to: arthernan (#4)
Re: Where can I find the code for extern OidFunctionCall7?

The comments on this sourcebase are really good, plus it is very well
structured!

I read somewhere that you can actually "store" an execution plan by using
stored procedures. If that is the case. I would imagine that variables would
prevent the histograms from being used. I don't mind finding the code
myself, but... Where is the code that does that switch? Clues are welcome
too!!

--
View this message in context: http://postgresql.1045698.n5.nabble.com/Where-can-I-find-the-code-for-extern-OidFunctionCall7-tp5769737p5769800.html
Sent from the PostgreSQL - hackers mailing list archive at Nabble.com.

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#6arthernan
arthernan@hotmail.com
In reply to: arthernan (#5)
Re: Where can I find the code for extern OidFunctionCall7?

Never mind I think I found it.

--
View this message in context: http://postgresql.1045698.n5.nabble.com/Where-can-I-find-the-code-for-extern-OidFunctionCall7-tp5769737p5769801.html
Sent from the PostgreSQL - hackers mailing list archive at Nabble.com.

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers