Re: Calling functions from queries
From: Dale Fye (dale.fye_at_nospam.com)
Date: 08/25/04
- Next message: Dale Fye: "Re: Help with logic"
- Previous message: Ken Snell [MVP]: "Re: Puzzling Problem"
- In reply to: ABL: "Calling functions from queries"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 24 Aug 2004 20:25:19 -0400
If you find that running the query with all the function calls takes too
long, and the values being passed to the function are a rather distinct set
of values (integers within a reasonable range), then you could create a
lookup table with the parameter values in one or more columns and the
results of the function as a column. If this is a function you call
frequently in your program, you might want to make this a permanent table.
If it is one that is called infrequently, you might only want to create it
the first time it is needed during a particular session and then delete it
during your programs shutdown process. The advantage of this latter method
would be that you could build it at runtime to contain only those parameter
values that are needed (see sample code below).
Then, when you write your query, you could do one of two things:
1. Call DLOOKUP instead of the function
2. Add a copy of this lookup table to the query for each of the function
calls, with joins between the parameter fields.
Lets assume that you have three fields that you are using for parameters to
your function. The SQL to build this temporary table might look something
like.
SELECT ParamValue, fnYourFunction([ParamValue])
FROM (SELECT Field1 as ParamValue
FROM yourTable
UNION
SELECT Field2 as ParamValue
FROM yourTable
UNION
SELECT Field3 as ParamValue
FROM yourTable) as T
HTH
Dale
"ABL" <ablnews@newsguy.com> wrote in message
news:cgfv4i02iua@news1.newsguy.com...
> I have a query that has calculated fields and joins in it. I am
> wondering what kind of performance hit I might expect if I have to call
> functions 8 times(!) per row returned.
>
> 6 of these calls are to two functions (3 each) with different values.
> All 8 columns are consecutive. Would it be quicker to call one big
> function and return the "8 columns" in one big string (I am not using
> header rows, and these calculations are read only, so I don't need to
> change them)?
>
> Any suggestions for increasing performance are welcome.
>
> I am using A2K.
>
> Thanks,
> Alden
>
> Plese reply only to the newsgroup. This email address is seldom checked
> and is used to catch unsolicited email.
- Next message: Dale Fye: "Re: Help with logic"
- Previous message: Ken Snell [MVP]: "Re: Puzzling Problem"
- In reply to: ABL: "Calling functions from queries"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|