View Single Post

   
  #2 (permalink)  
Old 04-19-2008, 08:53 PM
Paul G. Brown
 
Posts: n/a
Default Re: C UDR returns mi_double_precision

evg_vain@yahoo.com (Evgeny Vainerman) wrote in message news:<3824a12c.0401110129.6a75b690@posting.google. com>...
> I want to run a C UDR that returns CDOUBLETYPE (mi_double_precision).
> As far as I understood from the guide, the function cannot return
> mi_double_precision by value, the only one option - by reference.
> Following this constraint, I allocate a portion of memory with
> mi_alloc and return the pointer.
>
> The performance of the function is dramatically low! My assuming -
> because of allocation.
>
> Another option is to keep static variable and re-use it, but avoid
> parallel execution of the function - also undesirable.
>
> Is there alternative approach? Is it possible to avoid allocation?


A) Please define "dramatically slow"? Seconds? Minutes? Too many
nano-seconds?

B) Look in the log. Is the engine saying something to the effect
that it is barfing whenever it invokes the function (stuff about
memory being bad, barfing)?

C) Are you evaluating the performance of the UDF the first time it
is run (which involves loading and linking thee shared library) or by
running a big query that invokes the function say, 1000 times?

The mi_alloc() call is not zero cost, but if you're just
allocating an 8 byte block to hold a return value then it ought not be
signifigant.
Reply With Quote