473,626 Members | 3,413 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Slow Append Query

I have an append query that needs to run every time a line item is
added to a subform. The append writes to a table that is the source
for a pull down box. Problem is that it takes 5 seconds to run. This
makes adding lines to an order too slow for the users. The result of
the query provides real time availabilty, so I really do need this to
work.

The tblJobs has only 10,000 records, tblJobsLineItem s has 150,000
records.

INSERT INTO tmpRaItemsInUse Totals ( [Item Number], SumOfQuantity )
SELECT DISTINCTROW tblJobsLineItem s.[Item Number],
Sum(tblJobsLine Items.Quantity) AS SumOfQuantity
FROM tblJobs INNER JOIN tblJobsLineItem s ON tblJobs.Job_Num =
tblJobsLineItem s.Job_Num
WHERE (((tblJobs.Conf irmed)<>"no") AND ((tblJobs.SetCa ll) Between
[Forms]![frmJobs]![SetCall] And [Forms]![frmJobs]![fldRTSCall])) OR
(((tblJobs.Conf irmed)<>"no") AND ((tblJobs.fldRT SCall) Between
[Forms]![frmJobs]![SetCall] And [Forms]![frmJobs]![fldRTSCall])) OR
(((tblJobs.Conf irmed)<>"no") AND
((tblJobs.SetCa ll)<[Forms]![frmJobs]![SetCall]) AND
((tblJobs.fldRT SCall)>[Forms]![frmJobs]![fldRTSCall]))
GROUP BY tblJobsLineItem s.[Item Number];

Any ideas?

Oct 29 '06 #1
4 5750
Not sure I understand the WHERE clause.

All phrases have
tblJobs.Confirm ed <"no"
It will therefore be more effient to break that out and use:

WHERE (tblJobs.Confir med <"no")
AND ((tblJobs.SetCa ll Between [Forms]![frmJobs]![SetCall]
And [Forms]![frmJobs]![fldRTSCall])
OR (tblJobs.fldRTS Call Between [Forms]![frmJobs]![SetCall]
And [Forms]![frmJobs]![fldRTSCall])
OR ((tblJobs.SetCa ll < [Forms]![frmJobs]![SetCall])
AND (tblJobs.fldRTS Call [Forms]![frmJobs]![fldRTSCall])))

What I don't understand is that the criteria accepts SetCall between the 2
values in the form, or beyond those values. The effect of that would be to
accept all non-null values for this field? Could you use:

WHERE (tblJobs.Confir med <"no")
AND ((tblJobs.SetCa ll Is Not Null)
OR (tblJobs.fldRTS Call Between [Forms]![frmJobs]![SetCall]
And [Forms]![frmJobs]![fldRTSCall]))

Other suggestions:
- Make sure you have indexes on Confirmed, SetCall, fldRTSCall, and [Item
Number].

- Make sure you have a relation with Referential Integrity between the 2
tables (so the foreign key is indexed.)

- Any chance of using a yes/no field instead of a Text field for Confirmed?

- Unless SetCall and fldRTSCall are Text fields, declare the parameters.
Choose Parameters in the Query menu, and enter 2 rows into the dialog for:
[Forms]![frmJobs]![SetCall]
[Forms]![frmJobs]![fldRTSCall]
Alternatively, concatenate the values into the string, and execute it.

If it is still slow, see Tony Toews' Performance FAQ at:
http://www.granite.ab.ca/access/performancefaq.htm

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<pm********@gma il.comwrote in message
news:11******** **************@ h48g2000cwc.goo glegroups.com.. .
>I have an append query that needs to run every time a line item is
added to a subform. The append writes to a table that is the source
for a pull down box. Problem is that it takes 5 seconds to run. This
makes adding lines to an order too slow for the users. The result of
the query provides real time availabilty, so I really do need this to
work.

The tblJobs has only 10,000 records, tblJobsLineItem s has 150,000
records.

INSERT INTO tmpRaItemsInUse Totals ( [Item Number], SumOfQuantity )
SELECT DISTINCTROW tblJobsLineItem s.[Item Number],
Sum(tblJobsLine Items.Quantity) AS SumOfQuantity
FROM tblJobs INNER JOIN tblJobsLineItem s ON tblJobs.Job_Num =
tblJobsLineItem s.Job_Num
WHERE (((tblJobs.Conf irmed)<>"no") AND ((tblJobs.SetCa ll) Between
[Forms]![frmJobs]![SetCall] And [Forms]![frmJobs]![fldRTSCall])) OR
(((tblJobs.Conf irmed)<>"no") AND ((tblJobs.fldRT SCall) Between
[Forms]![frmJobs]![SetCall] And [Forms]![frmJobs]![fldRTSCall])) OR
(((tblJobs.Conf irmed)<>"no") AND
((tblJobs.SetCa ll)<[Forms]![frmJobs]![SetCall]) AND
((tblJobs.fldRT SCall)>[Forms]![frmJobs]![fldRTSCall]))
GROUP BY tblJobsLineItem s.[Item Number];

Any ideas?

Oct 29 '06 #2
pm********@gmai l.com wrote:
I have an append query that needs to run every time a line item is
added to a subform. The append writes to a table that is the source
for a pull down box. Problem is that it takes 5 seconds to run. This
makes adding lines to an order too slow for the users. The result of
the query provides real time availabilty, so I really do need this to
work.

The tblJobs has only 10,000 records, tblJobsLineItem s has 150,000
records.

INSERT INTO tmpRaItemsInUse Totals ( [Item Number], SumOfQuantity )
SELECT DISTINCTROW tblJobsLineItem s.[Item Number],
Sum(tblJobsLine Items.Quantity) AS SumOfQuantity
FROM tblJobs INNER JOIN tblJobsLineItem s ON tblJobs.Job_Num =
tblJobsLineItem s.Job_Num
WHERE (((tblJobs.Conf irmed)<>"no") AND ((tblJobs.SetCa ll) Between
[Forms]![frmJobs]![SetCall] And [Forms]![frmJobs]![fldRTSCall])) OR
(((tblJobs.Conf irmed)<>"no") AND ((tblJobs.fldRT SCall) Between
[Forms]![frmJobs]![SetCall] And [Forms]![frmJobs]![fldRTSCall])) OR
(((tblJobs.Conf irmed)<>"no") AND
((tblJobs.SetCa ll)<[Forms]![frmJobs]![SetCall]) AND
((tblJobs.fldRT SCall)>[Forms]![frmJobs]![fldRTSCall]))
GROUP BY tblJobsLineItem s.[Item Number];

Any ideas?
Are Item Number, Confirmed, SetCall, fldRTSCAll all indexed?

Once the append is performed, do you need to requery the dropdown? Do
you then display 10,000+ records in the dropdown?

Have you executed this query by itself?

What happens if you separate the insert from the Select? Maybe make the
select a query, then do the insert off the query.

How many records do you append each time you run the query? It appears
you append all summary line item records. That sounds ineffecient. Why
not do the append just for the job?

Oct 29 '06 #3
Thanks,

This only returns 10 - 20 rows. I will break out into select and
benchmark the time. Everything is indexed that is criteria or sorted.
I will also try Tony's adding Relationship as there is none there.

P

salad wrote:
pm********@gmai l.com wrote:
I have an append query that needs to run every time a line item is
added to a subform. The append writes to a table that is the source
for a pull down box. Problem is that it takes 5 seconds to run. This
makes adding lines to an order too slow for the users. The result of
the query provides real time availabilty, so I really do need this to
work.

The tblJobs has only 10,000 records, tblJobsLineItem s has 150,000
records.

INSERT INTO tmpRaItemsInUse Totals ( [Item Number], SumOfQuantity )
SELECT DISTINCTROW tblJobsLineItem s.[Item Number],
Sum(tblJobsLine Items.Quantity) AS SumOfQuantity
FROM tblJobs INNER JOIN tblJobsLineItem s ON tblJobs.Job_Num =
tblJobsLineItem s.Job_Num
WHERE (((tblJobs.Conf irmed)<>"no") AND ((tblJobs.SetCa ll) Between
[Forms]![frmJobs]![SetCall] And [Forms]![frmJobs]![fldRTSCall])) OR
(((tblJobs.Conf irmed)<>"no") AND ((tblJobs.fldRT SCall) Between
[Forms]![frmJobs]![SetCall] And [Forms]![frmJobs]![fldRTSCall])) OR
(((tblJobs.Conf irmed)<>"no") AND
((tblJobs.SetCa ll)<[Forms]![frmJobs]![SetCall]) AND
((tblJobs.fldRT SCall)>[Forms]![frmJobs]![fldRTSCall]))
GROUP BY tblJobsLineItem s.[Item Number];

Any ideas?
Are Item Number, Confirmed, SetCall, fldRTSCAll all indexed?

Once the append is performed, do you need to requery the dropdown? Do
you then display 10,000+ records in the dropdown?

Have you executed this query by itself?

What happens if you separate the insert from the Select? Maybe make the
select a query, then do the insert off the query.

How many records do you append each time you run the query? It appears
you append all summary line item records. That sounds ineffecient. Why
not do the append just for the job?
Oct 29 '06 #4

pm********@gmai l.com wrote:
Thanks,

This only returns 10 - 20 rows. I will break out into select and
benchmark the time. Everything is indexed that is criteria or sorted.
I will also try Tony's adding Relationship as there is none there.

P

salad wrote:
pm********@gmai l.com wrote:
I have an append query that needs to run every time a line item is
added to a subform. The append writes to a table that is the source
for a pull down box. Problem is that it takes 5 seconds to run. This
makes adding lines to an order too slow for the users. The result of
the query provides real time availabilty, so I really do need this to
work.
>
The tblJobs has only 10,000 records, tblJobsLineItem s has 150,000
records.
>
INSERT INTO tmpRaItemsInUse Totals ( [Item Number], SumOfQuantity )
SELECT DISTINCTROW tblJobsLineItem s.[Item Number],
Sum(tblJobsLine Items.Quantity) AS SumOfQuantity
FROM tblJobs INNER JOIN tblJobsLineItem s ON tblJobs.Job_Num =
tblJobsLineItem s.Job_Num
WHERE (((tblJobs.Conf irmed)<>"no") AND ((tblJobs.SetCa ll) Between
[Forms]![frmJobs]![SetCall] And [Forms]![frmJobs]![fldRTSCall])) OR
(((tblJobs.Conf irmed)<>"no") AND ((tblJobs.fldRT SCall) Between
[Forms]![frmJobs]![SetCall] And [Forms]![frmJobs]![fldRTSCall])) OR
(((tblJobs.Conf irmed)<>"no") AND
((tblJobs.SetCa ll)<[Forms]![frmJobs]![SetCall]) AND
((tblJobs.fldRT SCall)>[Forms]![frmJobs]![fldRTSCall]))
GROUP BY tblJobsLineItem s.[Item Number];
>
Any ideas?
>
Are Item Number, Confirmed, SetCall, fldRTSCAll all indexed?

Once the append is performed, do you need to requery the dropdown? Do
you then display 10,000+ records in the dropdown?

Have you executed this query by itself?

What happens if you separate the insert from the Select? Maybe make the
select a query, then do the insert off the query.

How many records do you append each time you run the query? It appears
you append all summary line item records. That sounds ineffecient. Why
not do the append just for the job?


Wow, what a difference. This difference between the Select and Append
was negligible. Re-arranging the syntax relating to the "No" criteria
was also negligible.

Adding the relationship between the tables took the elasped time from
over 5 seconds, to 0.515625 secs. That is great. Many thanks to
Allen and the rest. And sorry about the mis-quote above.

P

Oct 29 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1936
by: Yonatan Goraly | last post by:
I have a query that uses the same view 6 times. It seems that the database engine is calculating the view each time. The result is very poor performance. The same query takes 2 sec with MS SQL, and more than 10 sec with PostgreSQL. Is there a method to improve the performance besides merging the components of the view into one table? I believe that caching query results could have resolved this issue Yonatan Goraly
4
5366
by: sherkozmo | last post by:
SQL2000 - AccessXP I built an adp file with a stored procedure from SQL as follows: SELECT * FROM Z_mis_sjk_job_code_access WHERE job_code=@JobCode UNION ALL SELECT * FROM Z_mis_sjk_job_code_access_mkey WHERE job_code=@JobCode ORDER BY app_only, submenu_number, menu_routine_number,
2
1842
by: Danny | last post by:
I want to extract a subset of fields from one table into another the master table has many fields the subset has about half, but still many. Is there a way I can just append the master into the subsets structure and this way only the existing fields in the destination will be filled? That would be great, but it seems that the append query wants you to specify the fields. is there another way around this? I want to do it in code and it...
1
2477
by: David Barger | last post by:
Greetings, It appears that an Append Query I run in Access XP is randomly failing to append a field. I have payroll data being entered into a payroll database. This data is exported daily to two csv files. (One for updated data, and the other for unupdated data.) The CSV files are attached to my Jobcosting database. After the CSV
4
2134
by: Bri | last post by:
Hi, First let me explain the process I have going on, then I'll address the problems I'm having: 1) Insert records in a temp table using a query 2) Using a query that joins the temp table with TableA Insert records into TableB 3) Delete records from temp Table 4) Table specs; temp Table - 4 fields, 3 indexes, gets 100-4500 records inserted
2
5678
by: Otto Blomqvist | last post by:
Hello ! I have two tables (which contains individual months' data). One of them contains 500 thousand records and the other one about 40k, 8 columns. When I do a simple query on them individually it takes milli-seconds to complete (see gory details below). For some querys I want to include data from multiple months so I created a view using Union all. But Using the view it takes 31 Seconds to complete the "same" query.
0
1522
by: Rog | last post by:
I have two append queries that each append records from an SQL table into a temporary Access table in the frontend. All of a sudden one of them has become very slow - it takes a minute before the "you are about to run an append query" is displayed, then several more minutes to append a few hundred records. I recreated the query, but the result is still the same. Strange thing is that when I rename (or recreate) the query, so that it's...
4
1743
by: Ivan Voras | last post by:
I have a simple network protocol client (it's a part of this: http://sqlcached.sourceforge.net) implemented in Python, PHP and C. Everything's fine, except that the Python implementation is the slowest - up to 30% slower than the PHP version (which implements exactly the same logic, in a class). In typical usage (also in the benchmark), an object is created and ..query is called repeatedly. Typical numbers for the benchmark are: For...
4
5229
by: Rick | last post by:
Access2003 in XP I'm using the code below to append any new records from (tbl_From_Mainframe) into (tbl_Appended_Data). It takes more than a minute to search 7000 records for a dozen new records. The file I'm searching is in a data farm so I'm stuck with using it in its present format. Linking to the file or importing it as a local table have no effect on speed. How can I get this code to perform quicker?
0
8272
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8205
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8644
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8370
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7206
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5579
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4094
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4208
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2632
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.