Hearing from Brian that UDFs
might be slower than native functions in MySQL, I did a small
benchmark.
mysql> select benchmark(1e9,abs(1));
+-----------------------+
| benchmark(1e9,abs(1)) |
+-----------------------+
| 0 |
+-----------------------+
1 row in set (27.15 sec)
mysql> select benchmark(1e9,udf_abs(1));
+---------------------------+
| benchmark(1e9,udf_abs(1)) |
+---------------------------+
| 0 |
+---------------------------+
1 row in set (43.04 sec)
The numbers were taken on my MacBook (Core 2 Duo @ 2GHz, OS X
10.4.11) running the official binary version of MySQL 5.1.25-rc
for 32-bit arch. So the overhead of UDFs compared to native
functions seems to be about 30 clocks per each call.
So the question is whether it would matter on an actual
application. I created a 100k row heap table and performed …
[Read more]