Skip to content

Commit 0cc0d08

Browse files
committed
Document that get_attstatsslot/free_attstatsslot only need to be passed
valid type information if they are asked to fetch the values part of a pg_statistic slot; these arguments are unneeded if fetching only the numbers part. Use this to save a catcache lookup in btcostestimate, which is looking like a bit of a hotspot in recent profiling. Not a big savings, but since it's essentially free, might as well do it.
1 parent 07e6f93 commit 0cc0d08

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

src/backend/utils/adt/selfuncs.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*
1717
* IDENTIFICATION
18-
* $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.189 2005/09/24 22:54:38 tgl Exp $
18+
* $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.190 2005/10/11 17:27:14 tgl Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -4466,15 +4466,10 @@ btcostestimate(PG_FUNCTION_ARGS)
44664466

44674467
if (HeapTupleIsValid(tuple))
44684468
{
4469-
Oid typid;
4470-
int32 typmod;
44714469
float4 *numbers;
44724470
int nnumbers;
44734471

4474-
/* XXX this code would break with different storage type */
4475-
get_atttypetypmod(relid, colnum, &typid, &typmod);
4476-
4477-
if (get_attstatsslot(tuple, typid, typmod,
4472+
if (get_attstatsslot(tuple, InvalidOid, 0,
44784473
STATISTIC_KIND_CORRELATION,
44794474
index->ordering[0],
44804475
NULL, NULL, &numbers, &nnumbers))
@@ -4489,7 +4484,7 @@ btcostestimate(PG_FUNCTION_ARGS)
44894484
else
44904485
*indexCorrelation = varCorrelation;
44914486

4492-
free_attstatsslot(typid, NULL, 0, numbers, nnumbers);
4487+
free_attstatsslot(InvalidOid, NULL, 0, numbers, nnumbers);
44934488
}
44944489
ReleaseSysCache(tuple);
44954490
}

src/backend/utils/cache/lsyscache.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.127 2005/08/12 21:49:47 tgl Exp $
10+
* $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.128 2005/10/11 17:27:14 tgl Exp $
1111
*
1212
* NOTES
1313
* Eventually, the index information should go through here, too.
@@ -1841,8 +1841,8 @@ get_attavgwidth(Oid relid, AttrNumber attnum)
18411841
* entry, and we don't want to repeat the cache lookup unnecessarily.
18421842
*
18431843
* statstuple: pg_statistics tuple to be examined.
1844-
* atttype: type OID of attribute.
1845-
* atttypmod: typmod of attribute.
1844+
* atttype: type OID of attribute (can be InvalidOid if values == NULL).
1845+
* atttypmod: typmod of attribute (can be 0 if values == NULL).
18461846
* reqkind: STAKIND code for desired statistics slot kind.
18471847
* reqop: STAOP value wanted, or InvalidOid if don't care.
18481848
* values, nvalues: if not NULL, the slot's stavalues are extracted.
@@ -1960,6 +1960,12 @@ get_attstatsslot(HeapTuple statstuple,
19601960
return true;
19611961
}
19621962

1963+
/*
1964+
* free_attstatsslot
1965+
* Free data allocated by get_attstatsslot
1966+
*
1967+
* atttype need be valid only if values != NULL.
1968+
*/
19631969
void
19641970
free_attstatsslot(Oid atttype,
19651971
Datum *values, int nvalues,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy