Hi,
Yes, it calls the method twice, once to evaluate the condition "dist > 0.05", and once to get the row for result ("select name, dist"). To avoid that, you would need to use a small cache. There currently is no cache in H2, as a cache would slow down performance unnecessarily for simple methods, and is also not necessary for slow methods if the method is only used once (for example, just in the condition, or just in the result).
A workaround is to change the query slightly, to do the caching yourself, for example:
SELECT name, @dist as dist FROM (
SELECT name, DISTANCE(name, 'alex') as dist
FROM Person
)
WHERE (@dist := dist) > 0.05
ORDER BY dist DESC
LIMIT 5;
Regards,
Thomas