Database Reference
In-Depth Information
The final CREATE AGGREGATE puts all the pieces together and looks more or less the same
in all languages. Our PL/V8 variant is shown in Example 8-21 .
Example 8-21. PL/V8 geometric mean aggregate: putting all the pieces together
CREATE AGGREGATE geom_mean ( numeric ) (
SFUNC = geom_mean_state ,
STYPE = numeric [],
FINALFUNC = geom_mean_final ,
INITCOND = '{0,0}'
);
When you run Example 8-9 , calling to our new PL/V8 function, you get the same an‐
swers, but the PL/V8 version is two to three times faster. For mathematical operations,
you'll find that PL/V8 functions are 10 to 20 times faster than their SQL counterparts
in many cases.
Search WWH ::




Custom Search