aboutsummaryrefslogtreecommitdiff
path: root/contrib/pg_stat_statements/pg_stat_statements.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2015-03-28 13:56:37 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2015-03-28 13:56:37 -0400
commit2c33e0fbceb01d0ecd78330feef1315682c64bc4 (patch)
treed6a15151cc9bc1b8dcb9f3527387e1ca77658038 /contrib/pg_stat_statements/pg_stat_statements.c
parent7655f4ccea570d57c4d473cd66b755c03c904942 (diff)
downloadpostgresql-2c33e0fbceb01d0ecd78330feef1315682c64bc4.tar.gz
postgresql-2c33e0fbceb01d0ecd78330feef1315682c64bc4.zip
Better fix for misuse of Float8GetDatumFast().
We can use that macro as long as we put the value into a local variable. Commit 735cd6128 was not wrong on its own terms, but I think this way looks nicer, and it should save a few cycles on 32-bit machines.
Diffstat (limited to 'contrib/pg_stat_statements/pg_stat_statements.c')
-rw-r--r--contrib/pg_stat_statements/pg_stat_statements.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/contrib/pg_stat_statements/pg_stat_statements.c b/contrib/pg_stat_statements/pg_stat_statements.c
index da6c242631a..76d9e0a5ec6 100644
--- a/contrib/pg_stat_statements/pg_stat_statements.c
+++ b/contrib/pg_stat_statements/pg_stat_statements.c
@@ -1246,7 +1246,6 @@ pgss_store(const char *query, uint32 queryId,
e->counters.min_time = total_time;
if (e->counters.max_time < total_time)
e->counters.max_time = total_time;
-
}
e->counters.rows += rows;
e->counters.shared_blks_hit += bufusage->shared_blks_hit;
@@ -1491,6 +1490,7 @@ pg_stat_statements_internal(FunctionCallInfo fcinfo,
bool nulls[PG_STAT_STATEMENTS_COLS];
int i = 0;
Counters tmp;
+ double stddev;
int64 queryid = entry->key.queryid;
memset(values, 0, sizeof(values));
@@ -1577,15 +1577,12 @@ pg_stat_statements_internal(FunctionCallInfo fcinfo,
* sample variance, as we have data for the whole population,
* so Bessel's correction is not used, and we don't divide by
* tmp.calls - 1.
- *
- * We're calculating the stddev on the fly, so it's not in the tmp
- * structure, so we can't use the Float8GetDatumFast macro here.
*/
if (tmp.calls > 1)
- values[i++] =
- Float8GetDatum(sqrt(tmp.sum_var_time / tmp.calls));
+ stddev = sqrt(tmp.sum_var_time / tmp.calls);
else
- values[i++] = Float8GetDatum(0.0);
+ stddev = 0.0;
+ values[i++] = Float8GetDatumFast(stddev);
}
values[i++] = Int64GetDatumFast(tmp.rows);
values[i++] = Int64GetDatumFast(tmp.shared_blks_hit);