]> granicus.if.org Git - postgresql/commitdiff
Document that get_attstatsslot/free_attstatsslot only need to be passed
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 11 Oct 2005 17:27:14 +0000 (17:27 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 11 Oct 2005 17:27:14 +0000 (17:27 +0000)
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.

src/backend/utils/adt/selfuncs.c
src/backend/utils/cache/lsyscache.c

index e987a66a1cf09e2f68aa5a4da5657357e58885d9..ccc8d0f4483c2ecb2dd23580139fe4d1ef59a316 100644 (file)
@@ -15,7 +15,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.189 2005/09/24 22:54:38 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.190 2005/10/11 17:27:14 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -4466,15 +4466,10 @@ btcostestimate(PG_FUNCTION_ARGS)
 
        if (HeapTupleIsValid(tuple))
        {
-               Oid                     typid;
-               int32           typmod;
                float4     *numbers;
                int                     nnumbers;
 
-               /* XXX this code would break with different storage type */
-               get_atttypetypmod(relid, colnum, &typid, &typmod);
-
-               if (get_attstatsslot(tuple, typid, typmod,
+               if (get_attstatsslot(tuple, InvalidOid, 0,
                                                         STATISTIC_KIND_CORRELATION,
                                                         index->ordering[0],
                                                         NULL, NULL, &numbers, &nnumbers))
@@ -4489,7 +4484,7 @@ btcostestimate(PG_FUNCTION_ARGS)
                        else
                                *indexCorrelation = varCorrelation;
 
-                       free_attstatsslot(typid, NULL, 0, numbers, nnumbers);
+                       free_attstatsslot(InvalidOid, NULL, 0, numbers, nnumbers);
                }
                ReleaseSysCache(tuple);
        }
index 6b1646b896dcad285740e2b6e7196508a17ceae9..ebb884dc2583c686453d3c665797392a709ed1d3 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.127 2005/08/12 21:49:47 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.128 2005/10/11 17:27:14 tgl Exp $
  *
  * NOTES
  *       Eventually, the index information should go through here, too.
@@ -1841,8 +1841,8 @@ get_attavgwidth(Oid relid, AttrNumber attnum)
  * entry, and we don't want to repeat the cache lookup unnecessarily.
  *
  * statstuple: pg_statistics tuple to be examined.
- * atttype: type OID of attribute.
- * atttypmod: typmod of attribute.
+ * atttype: type OID of attribute (can be InvalidOid if values == NULL).
+ * atttypmod: typmod of attribute (can be 0 if values == NULL).
  * reqkind: STAKIND code for desired statistics slot kind.
  * reqop: STAOP value wanted, or InvalidOid if don't care.
  * values, nvalues: if not NULL, the slot's stavalues are extracted.
@@ -1960,6 +1960,12 @@ get_attstatsslot(HeapTuple statstuple,
        return true;
 }
 
+/*
+ * free_attstatsslot
+ *             Free data allocated by get_attstatsslot
+ *
+ * atttype need be valid only if values != NULL.
+ */
 void
 free_attstatsslot(Oid atttype,
                                  Datum *values, int nvalues,