Shorten union query

Union queries are not the fastest types of queries in the world :)

How many records are you pulling in total?
 
Union queries are not the fastest types of queries in the world :)

How many records are you pulling in total?


This is a total understatement. :eek:

I took a closer look at the example member Query, and noticed that there is no obvious reason for the GROUP BY Clause except for the fact that it is there. I am aware of the effect of the GROUP BY Clause, but I am also aware that the grouping and regrouping will slow down the processing as it occurs.

If the only reason for the grouping is for the presentation of the final data, then perhaps it can wait until all of the data has been extracted. Having each Union Member do a SELECT only and then having the GROUP BY done at the end of all of the selections, would change the scenario to make each extract Query faster, and the common Grouping slower, but the total time required might be somewhat less than it is now.

If this does not work, then changing each UNION member Query to an INSERT Query that appends to a Temp Table, and having a master Query to process the Temp Table into the final results could eliminate the resource issues. A Macro could be written to control the execution of the Queries.

NOTE: The following might be of interest to people viewing this thread:

http://thedailyreviewer.com/office/view/what-is-the-max-query-size-107203188
 
Last edited:
That was the kind of Union I was referring to ;)

Some Unions are useless though.
 

Users who are viewing this thread

Back
Top Bottom