Deano wrote:
Lyle Fairfield wrote:
Deano wrote:
I've not much experience in this even though i've read the correct
websites that have been listed here many times, down to tips about
not using domain aggregrate functions to improve performance
(admittedly that confuses me as I don't see how I could get by
without them, but I digress).
I haven't used a Domain Aggregate Function in this century. They used
to be SLOW, or at least that is my recollection and certainly the
reason, good or bad, that I abandoned them; but I believe that has
changed and that they are quite satisfactorily speedy now?
Well i'd love to hear from people about this because they are so
handy, not least of all in reports where I can use them to count
totals and use them with immediate IF statements to check for nulls
etc.
The magazine Total Access/VB/SQL Server (name probably not exact) once did tests
comparing all of the "usual" lookup methods and found that DLookup() was only
bested by "Seek" in any significant amount and since Seek is only useful against
local tables that pretty much makes the Domain functions perfectly legitimate
tools to use "as appropriate".
My understanding is that the downside of the domain aggregates is that they
instantiate a database collection in the same manner as...
Dim db as Database
Set db = CurrentDB
The above creates a copy of the current database *and* a refresh of all its
collections. It is this refresh which imposes an overhead "penalty" as compared
to...
Dim db as Database
Set db = DBEngine(0)(0)
....which does not refresh the collections.
So, while DBEngine(0)(0) is reported to be "thousands of times faster" most
developers acknowledge that this difference is only going to matter in a loop or
other usage which would cause the action to be repeated many times in a short
interval. So except in cases where this usage is expected, most just go ahead
and use CurrentDB.
The same holds true for the domain aggregate functions. If you use one in a
query that will process many rows or in a code looping operation the performance
is likely to be poor and a custom replacement can do better. However if the
custom function replacement uses CurrentDB you are simply replacing a poor
choice with an equally poor choice as you introduce the same overhead problems
that the domain function has.
It is also a widely held belief that the domain functions do not utilize
indexes. This is also false and easily disproved by simple testing. It is my
belief that in the early days of Access people saw bad performance from the
domain functions when they were used in queries and from this they earned the
reputation of being "poor performers" all around.
Some people simply prefer to use...
Dim val as Variant
Dim db As Database
Dim rs as Recordset
Set db = CurrentDB (or DBEngine(0)(0))
Set rs = db.OpenRecordSet("SomeQuery")
val = rs!SomeField
....instead of...
Dim val as Variant
val = Dlookup("SomeField", "SomeDomain")
....because they feel like they have more control and in many cases it offers
more flexibility, but unless one uses DBEngine(0)(0) there is no reason to
believe that the RecordSet method will be any faster or more efficient.
--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com