I have a function and pass it an integer e.g. 99, 4 or 3
The function returns a different integer (so effectively it transforms it)
Now I have found that this function is called in a select so for a 300 row import with all my related tables the total times the number transform function is called is 250k times!
This scares me a lot – My question is would this be better in a look up table that is joined to my query – thus removing the function from the select.
I would vote for look up table, as it can make use of the index of the table, if created
Also the function need not to be run for each row when running against a table
But one problem with look up table is that it should handle all possible inputs.
We can handle only limited cases with look up table.
So if you can create a look up table for all possible input, look up table has performance advantage over function