I have designed a form to bridge one customer record with a master customer record in a table. For example: CustomerName, CustomerNumber:
ABC Company, 101;
ABC Corp. , 102;
ABC Inc., 103;
ABC Co., 104;
ABC Comp., 105;
MasterCustomerName, MasterCustomerNum:
ABC Master, 1001 Bridge:
101, 1001;
102, 1001;
103, 1001;
104, 1001;
105, 1001
To give me the customers that have not yet been assigned to a Master Record, I wrote query that looks at a table and finds all customer numbers that are not in the Bridge table: - "SELECT DISTINCT CUSTOMER_NBR, CUSTOMER_NAME
-
FROM tblX
-
WHERE NOT Exists (SELECT BridgeCustomerNumber, From tblCustomerBridge WHERE BridgeCustomerNumber = CUSTOMER_NBR)
-
ORDER BY CUSTOMER_NAME;"
tblX has approx 500,000 records and it is taking about 10 to 12 seconds to run the query. I have to refresh the query every time I use the form to update the Bridge Table.
Any advice on how to speed up the runtime of the query?
Thanks in advance,
bplantes
3 1790
...tblX has approx 500,000 records and it is taking about 10 to 12 seconds to run the query. I have to refresh the query every time I use the form to update the Bridge Table.
Hi. Subqueries are very useful for certain tasks, but on large datasets the use of a subquery can lead to a performance hit as you are finding. As an alternative without the subquery, try the following, changing the field names to the proper ones before you do so: - SELECT tblX.[Customer No], tblX.[Customer Name]
-
FROM tblX LEFT JOIN Bridge ON tblX.[Customer No] = Bridge.Customer_Nbr
-
WHERE (((Bridge.Customer_Nbr) Is Null))
-
ORDER BY tblX.[Customer Name];
-
-
I don't know how it will perform on 500,000 records but the left-joined tables where all we want to find are nulls at the bridge end should be faster than the subquery I reckon.
-Stewart
Thanks for that... I have worked with MS SQL before and have used "Left Outer Join" which would only take the left, non-joined, records. Access doesn't seem to have that functionality. I just implemented this into the code and it worked great. Thanks for the help.
NeoPa 32,556
Expert Mod 16PB
MS SQL's LEFT [OUTER] JOIN (where the OUTER keyword is optional) is equivalent to Access's LEFT JOIN.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Angel Faus |
last post by:
Hi all,
We've got an Oracle database in a Web application. Intermedia Text
queries are an important part of the usage and work fine.
The problem is that in order to generate a certain web...
|
by: Bennett Haselton |
last post by:
I have a MySQL query running inside a CGI script on my site that, at random
intervals, seems to take 10-20 seconds to complete instead of less than 1
second. I spent so much time trying to track...
|
by: Apollo |
last post by:
I have about 20K records that result from the following query. Front end for the
database is ACCESS97 and pulling up 20K records makes a huge performance hit.
For the form in question I am using...
|
by: David |
last post by:
Consider this SQL Query:
-----------------------------------------------------------------
SELECT c.CASE_NBR, DATEDIFF(d, c.CREATE_DT, GETDATE()) AS Age,
c.AFFD_RCVD, c.PRV_CRD_ISS, x.RegE,...
|
by: John D |
last post by:
We have a dynamic SP that dependant on a user name will run a selected
tailored to them.
One of the criteria is the number of rows retrieved, which we include using
'top @varNoOfRows' in the...
|
by: mfyahya |
last post by:
Hi,
I'm new to databases :) I need help speeding up select queries on my
data which are currently taking 4-5 seconds. I set up a single large
table of coordinates data with an index on the fields...
|
by: Wayne |
last post by:
I am running a complex query using about 25 criteria that are entered
on a query form. If any individual criteria isn't required its field is
left as "*" on the form. When I run the query the...
|
by: simon_w3 |
last post by:
Hi All,
I'm trying to figure out how I can speed up a fragment of code (which
has been converted from vb6 to .NET) that reads data from a database.
My knowledge on database programming is...
|
by: Dan Sugalski |
last post by:
Is there any good way to speed up SQL that uses like and has placeholders?
Here's the scoop. I've got a system that uses a lot of pre-generated
SQL with placeholders in it. At runtime these SQL...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
| |