A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Opinion about aggregates



 
 
Thread Tools Display Modes
  #1  
Old April 13th, 2010, 10:35 AM posted to microsoft.public.access.queries
Rick Brandt
external usenet poster
 
Posts: 4,354
Default Opinion about aggregates

AccessKay wrote:

I’m fairly new to Access so this may be an inane question to all those
experienced people out there. My question is about the use of aggregates
in
a query. I’m noticing that designing queries with aggregates might lead
to
problems. Is it best to not build queries with aggregates if you can
avoid it?

Thanks for any feedback.


If you mean the "domain aggregate functions" e.g. DLookup(), DSum(),
DCount(), etc., then yes they should be avoided whenever possible in
queries.

The reason is that these functions all have a bit of resource overhead that
is consumed for each call. That means calling them in queries or code
looping operations results in paying that overhead over and over and over.

The normal aggregate functions like Sum(), Count(), Min(), etc., are
perfectly fine in queries. Databases would be pretty useless without them.

  #2  
Old April 13th, 2010, 03:25 PM posted to microsoft.public.access.queries
AccessKay
external usenet poster
 
Posts: 106
Default Opinion about aggregates

I’m fairly new to Access so this may be an inane question to all those
experienced people out there. My question is about the use of aggregates in
a query. I’m noticing that designing queries with aggregates might lead to
problems. Is it best to not build queries with aggregates if you can avoid
it?

Thanks for any feedback.

  #3  
Old April 13th, 2010, 03:35 PM posted to microsoft.public.access.queries
Jerry Whittle
external usenet poster
 
Posts: 4,732
Default Opinion about aggregates

If you are talking about things like DCount, DMax, and such, they can be
really slow if you have a lot (like 50,000+) records. I tend to avoid them if
possible.

On the other hand, Totals queries are very useful to summerize data.
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


"AccessKay" wrote:

I’m fairly new to Access so this may be an inane question to all those
experienced people out there. My question is about the use of aggregates in
a query. I’m noticing that designing queries with aggregates might lead to
problems. Is it best to not build queries with aggregates if you can avoid
it?

Thanks for any feedback.

  #4  
Old April 13th, 2010, 04:07 PM posted to microsoft.public.access.queries
AccessKay
external usenet poster
 
Posts: 106
Default Opinion about aggregates

Thanks. I’m going to take it as a rule to avoid using domain aggregate
functions if at all possible. Though not sure yet as to how to workaround it
but I still have lots more to learn.

"Jerry Whittle" wrote:

If you are talking about things like DCount, DMax, and such, they can be
really slow if you have a lot (like 50,000+) records. I tend to avoid them if
possible.

On the other hand, Totals queries are very useful to summerize data.
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


"AccessKay" wrote:

I’m fairly new to Access so this may be an inane question to all those
experienced people out there. My question is about the use of aggregates in
a query. I’m noticing that designing queries with aggregates might lead to
problems. Is it best to not build queries with aggregates if you can avoid
it?

Thanks for any feedback.

  #5  
Old April 13th, 2010, 04:18 PM posted to microsoft.public.access.queries
Bob Barrows
external usenet poster
 
Posts: 475
Default Opinion about aggregates

When you get around to it, the alternative is to use correlated
subqueries. I'm not going to go into a lot of detail here because it
sounds like you're not ready to use them yet. You can look up the topic
about subqueries in online help when the time comes so you'll have a
starting point.

AccessKay wrote:
Thanks. I'm going to take it as a rule to avoid using domain
aggregate functions if at all possible. Though not sure yet as to
how to workaround it but I still have lots more to learn.

"Jerry Whittle" wrote:

If you are talking about things like DCount, DMax, and such, they
can be really slow if you have a lot (like 50,000+) records. I tend
to avoid them if possible.

On the other hand, Totals queries are very useful to summerize data.
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


"AccessKay" wrote:

I'm fairly new to Access so this may be an inane question to all
those experienced people out there. My question is about the use
of aggregates in a query. I'm noticing that designing queries with
aggregates might lead to problems. Is it best to not build queries
with aggregates if you can avoid it?

Thanks for any feedback.


--
HTH,
Bob Barrows


  #6  
Old April 13th, 2010, 05:12 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default Opinion about aggregates

It depends. I do tend to avoid them in queries for performance reasons. BUT
if I know that the query needs to be updateable and I know that there will be
a limited number of records returned I will use the aggregate functions.
However, I never apply criteria against an aggregate function in a query.
That could lead to the query engine doing the calculation for EVERY record in
the table in order to apply the filter.


John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

AccessKay wrote:
I’m fairly new to Access so this may be an inane question to all those
experienced people out there. My question is about the use of aggregates in
a query. I’m noticing that designing queries with aggregates might lead to
problems. Is it best to not build queries with aggregates if you can avoid
it?

Thanks for any feedback.

  #7  
Old April 13th, 2010, 05:52 PM posted to microsoft.public.access.queries
AccessKay
external usenet poster
 
Posts: 106
Default Opinion about aggregates

Thanks Bob for letting me know about correlated subqueries. Thanks also John
for your insight about when you might make an exception to the rule.

I appreciate all the excellent feedback from all!


"John Spencer" wrote:

It depends. I do tend to avoid them in queries for performance reasons. BUT
if I know that the query needs to be updateable and I know that there will be
a limited number of records returned I will use the aggregate functions.
However, I never apply criteria against an aggregate function in a query.
That could lead to the query engine doing the calculation for EVERY record in
the table in order to apply the filter.


John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

AccessKay wrote:
I’m fairly new to Access so this may be an inane question to all those
experienced people out there. My question is about the use of aggregates in
a query. I’m noticing that designing queries with aggregates might lead to
problems. Is it best to not build queries with aggregates if you can avoid
it?

Thanks for any feedback.

.

  #8  
Old April 13th, 2010, 07:46 PM posted to microsoft.public.access.queries
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Opinion about aggregates

On Tue, 13 Apr 2010 07:25:01 -0700, AccessKay
wrote:

I’m fairly new to Access so this may be an inane question to all those
experienced people out there. My question is about the use of aggregates in
a query. I’m noticing that designing queries with aggregates might lead to
problems. Is it best to not build queries with aggregates if you can avoid
it?

Thanks for any feedback.


Ummm...

Is it best to use a woodworking shop without using the table saw? Table saws
can be dangerous!

Of course you should use aggregate queries, when an aggregate query is the
tool to do what you need done. Sure, they can be used inappropriately, and you
have to understand how they work; but that's no reason not to use them. They
exist to be used!
--

John W. Vinson [MVP]
  #9  
Old April 14th, 2010, 06:47 AM posted to microsoft.public.access.queries
david
external usenet poster
 
Posts: 398
Default Opinion about aggregates

Aggregate queries use things like MAX, MIN, SUM, FIRST.
Using queries with aggregates might lead to problems: for this
reason it is sometimes better to use the Domain Aggregate
Functions (things like DMAX, DMIN, DSUM, DLOOKUP).

Domain Aggregate Functions are slower, but they avoid some
of the problems with Aggregate Queries and Correlated
Subqueries.

The problem with Correlated Subqueries is mostly that
they are a bit slow, a bit tricky, and a bit difficult to set up.

The problem with Aggregate queries is that they turn your
select queries into read-only, and sometimes they fail or
give the wrong result if they are very complex.

The problem with Domain Aggregate Functions is that they
are slow, and require tables to be in the Current Database,
(which is only a problem if you are using references, or
querying an unlinked database).

So the answer is, you should only use queries which return
the maximum, minimum, average, sum, count or whatever
if you need a query to return the maximum, minimum, average,
sum, count or whatever, and when you do, you have a
choice of using a report, or three different query methods.

(david)

"AccessKay" wrote in message
...
I'm fairly new to Access so this may be an inane question to all those
experienced people out there. My question is about the use of aggregates
in
a query. I'm noticing that designing queries with aggregates might lead
to
problems. Is it best to not build queries with aggregates if you can
avoid
it?

Thanks for any feedback.



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:26 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.