473,403 Members | 2,183 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Question regarding Compiling Queries

Denburt
1,356 Expert 1GB
According to our lovely friends at Microsoft they say that after compacting a database the queries should be recompiled by opening each one then closing it. So I compacted the database I was currently working on and it was about 100 megs down to a mere 30 megs. I wrote a routine to cycle through and run each of my queries, I then watched it run lol (crapped out twice Hmmm). Looks like i need an external log to see which one it hangs on. Well after running most of the queries (and crashed lol) it is 45 megs O.K. I can deal with this I guess if it is for performance size isn't as big an issue.

My question is though according to the following article:
http://support.microsoft.com/kb/209126

They mentioned several things about queries but I think they were vague. In the article they mentioned timing of a query.
There are two significant time measurements for a Select query: • Time to display the first screen of data
• Time to obtain the last record
If a query returns only one screen of data, these two time measurements are the same. If a query returns many records, these time measurements can be very different.
Then later this.
After you compact your database, run each query to compile the query so that each query will now have the updated table statistics.
So if we are opening the query to optimize it, we are doing so to update table statistics. Does this mean that we should open each query then scroll to the last record or is merely opening the query then closing it enough to fully compile it? Did I miss something in the article or are they just not very clear about this?

TIA
Apr 11 '07 #1
7 3947
NeoPa
32,556 Expert Mod 16PB
The statistics are updated whenever a query is compiled. A query is flagged for compiling when you save any changes to the query (or its underlying tables) and when the database is compacted. If a query is flagged for compiling, the compiling and the updating of statistics occurs the next time that the query is run. Compiling typically takes from one second to four seconds.

If you add a significant number of records to your database, you must open and then save your queries to recompile the queries. For example, if you design and then test a query by using a small set of sample data, you must re-compile the query after additional records are added to the database. When you do this, you want to make sure that optimal query performance is achieved when your application is in use.
From the article, I would say merely opening it and saving it would do the trick.
By the time it's shown any records it has already processed through the optimisation stage.
Interesting article. Some new info for me :)
Apr 11 '07 #2
Denburt
1,356 Expert 1GB
Thanks that was the same thinking I had but not sure. It also stated that the queries that need optimization were flagged somehow but didn't say how or where this "Flag" could be found or how to access it. i am thinking it may be in a system table but not sure. This could save a LOT of time and save on the bloating issue, most of my db's have a LOT of queries some of which may take a few minutes to run.
Apr 11 '07 #3
Denburt
1,356 Expert 1GB
I thought I would throw this out there in case anyone was interested.

Expand|Select|Wrap|Line Numbers
  1. Public Function ComileQueries()
  2. Dim Q As Object
  3. Dim db As Database
  4. Set db = CurrentDb
  5. For Each Q In db.QueryDefs
  6.     If Not Q.Name Like "~*" Then
  7.         'Debug.Print Q.Type & "   " & Q.Name
  8.         Select Case Q.Type
  9.             'Select Queries are 0 and Union queries are 128
  10.             Case 0, 128
  11.                 On Error Resume Next
  12.                 DoCmd.OpenQuery Q.Name
  13.                 'If a table was removed and the query still refers to it a 3192 error will occur
  14.                 If Err.Number = 3192 Then
  15.                     Debug.Print Q.Name
  16.                 Else
  17.                     DoCmd.Close acQuery, Q.Name
  18.                 End If
  19.         End Select
  20.     End If
  21. Next
  22. Set db = Nothing
  23. End Function
  24.  
Apr 11 '07 #4
NeoPa
32,556 Expert Mod 16PB
I don't think they wanted to publish where this extra object data is held (Essentially a dirty flag). It may be discoverable with some digging in the system tables, or even on the web maybe...
As for your routine, although you only run the safe ones (SELECT & UNION) remember that the other queries will be in the same state and will benefit from being run too (probably manually :().
Apr 11 '07 #5
ADezii
8,834 Expert 8TB
According to our lovely friends at Microsoft they say that after compacting a database the queries should be recompiled by opening each one then closing it. So I compacted the database I was currently working on and it was about 100 megs down to a mere 30 megs. I wrote a routine to cycle through and run each of my queries, I then watched it run lol (crapped out twice Hmmm). Looks like i need an external log to see which one it hangs on. Well after running most of the queries (and crashed lol) it is 45 megs O.K. I can deal with this I guess if it is for performance size isn't as big an issue.

My question is though according to the following article:
http://support.microsoft.com/kb/209126

They mentioned several things about queries but I think they were vague. In the article they mentioned timing of a query.


Then later this.


So if we are opening the query to optimize it, we are doing so to update table statistics. Does this mean that we should open each query then scroll to the last record or is merely opening the query then closing it enough to fully compile it? Did I miss something in the article or are they just not very clear about this?

TIA
I think you may have missed a step. In order to recompile a Query, you must:
  1. Open the Query in Design Mode.
  2. Save it.
  3. Reexecute it.
  4. Simply running Queries will not recompile them.
Apr 11 '07 #6
Denburt
1,356 Expert 1GB
Thanks for the input ADezii and Neopa looks like I have a little more work to do. I also found that I need to check the SQL statement for form links as well so this could get interesting. Once I get it together I will repost it and see what yall think.
Apr 12 '07 #7
NeoPa
32,556 Expert Mod 16PB
I think you may have missed a step. In order to recompile a Query, you must:
  1. Open the Query in Design Mode.
  2. Save it.
  3. Reexecute it.
  4. Simply running Queries will not recompile them.
Re: Point 4 - Are you sure about that ADezii?
If you refer to the quoted part of post #2 it suggests otherwise.
Apr 12 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: JMCN | last post by:
Here is a simple question regarding insert into and select insert into statements. I have the follwing sql from my table make query. how can i add other query with the same field names as tbl1? ...
9
by: noone | last post by:
I have a database file that I use an autonumber field as the primary key index. Because of some rearrangements in the past, this index does not match the order that I would like it to be in, that...
18
by: Andre Laplume via AccessMonster.com | last post by:
I have inherited a bunch of dbs which are are shared among a small group in my dept. We typically use the dbs to write queries to extract data, usually dumping it into Excel. Most dbs originated...
10
by: jojobar | last post by:
Hello, I am trying to use vs.net 2005 to migrate a project originally in vs.net 2003. I started with creation of a "web site", and then created folders for each component of the site. I read...
12
by: sunil | last post by:
Hi All, Please have a look the below program #include<stdlib.h> int i = system("pwd"); I compiled the above program in UNIX ,it got compiled and executed with out any errors.It prints the...
5
by: Regnab | last post by:
I have a table "tblSprayApplication" in a project for a nursery. Each record refers to a single spray application across the nursery, recording which groups had been sprayed. Multiple applications...
10
by: sam_cit | last post by:
Hi Everyone, I had a doubt regarding extern decleration, i tried this is one source file, extern int sample; extern int sample; int main() {
5
by: polas | last post by:
Good morning, I have a quick question to clear up some confusion in my mind. I understand that using a string literal in a declaration such as char *p = "string literal" declares a pointer to...
0
bleurose
by: bleurose | last post by:
We have a modestly large MySQL application (about 10,000,000 rows spread over 40+ tables). Most of our queries are very small and fast (single table or two-table joins with good keys and indexes). ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.