473,395 Members | 1,891 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,395 software developers and data experts.

Query takes hours

MS Access XP, running on Win XP, Processor 2.4Ghz , 512Mb RAM, 40Gb Hard
drive

Table 1 has 167,000 records and contains the following fields
tblone_custID
tblone_easting
tblone_northing

Table 2 has 423,000 records and contains the following fields
tbltwo_custID
tbltwo_easting
tbltwo_northing

Table 1 and Table 2 does have other fields but the ones I have listed are
the key ones to explain my problem. And that problem is that table 2
contains dirty data and table 1 the good data. For both tables the CustID is
unique and there are no CustID's in table 2 that are in table 1.

I am trying to extract from table 1 good data where the easting and northing
are close so I end up with a new table returning values from table 1 and
values from table 2. That way I can then re-populate later on the results
into table 1.

The query parameters as per design view

FIELD...........Expr1: Abs(tblone_easting - tbltwo_easting)
FIELD...........Expr2: Abs(tblone_northing - tbltwo_northing)

For each of these 2 fields I have a CRITERIA of "<10".

Understandably the query will take a while, upto now its been running for 9
hrs (on my spare PC at work). And what I have realised while testing on my
PC at home is that when I eventually get results I cannot export the results
without the query re-running.

So therefore;
Q1: Is there a quicker way of querying "tbltwo" against "tblone" as per my
query parameters above.
Q2: If I am lucky enough to return to work and find I have results how can I
export those results without the query re-running.

many many thanks

Macroman


Mar 21 '06 #1
4 3687
DFS
Post the SQL statement and we'll take a look.

Macroman wrote:
MS Access XP, running on Win XP, Processor 2.4Ghz , 512Mb RAM, 40Gb
Hard drive

Table 1 has 167,000 records and contains the following fields
tblone_custID
tblone_easting
tblone_northing

Table 2 has 423,000 records and contains the following fields
tbltwo_custID
tbltwo_easting
tbltwo_northing

Table 1 and Table 2 does have other fields but the ones I have listed
are the key ones to explain my problem. And that problem is that
table 2 contains dirty data and table 1 the good data. For both
tables the CustID is unique and there are no CustID's in table 2 that
are in table 1.

I am trying to extract from table 1 good data where the easting and
northing are close so I end up with a new table returning values from
table 1 and values from table 2. That way I can then re-populate
later on the results into table 1.

The query parameters as per design view

FIELD...........Expr1: Abs(tblone_easting - tbltwo_easting)
FIELD...........Expr2: Abs(tblone_northing - tbltwo_northing)

For each of these 2 fields I have a CRITERIA of "<10".

Understandably the query will take a while, upto now its been running
for 9 hrs (on my spare PC at work). And what I have realised while
testing on my PC at home is that when I eventually get results I
cannot export the results without the query re-running.

So therefore;
Q1: Is there a quicker way of querying "tbltwo" against "tblone" as
per my query parameters above.
Q2: If I am lucky enough to return to work and find I have results
how can I export those results without the query re-running.

many many thanks

Macroman

Mar 21 '06 #2
Macroman wrote:
MS Access XP, running on Win XP, Processor 2.4Ghz , 512Mb RAM, 40Gb Hard
drive

Table 1 has 167,000 records and contains the following fields
tblone_custID
tblone_easting
tblone_northing

Table 2 has 423,000 records and contains the following fields
tbltwo_custID
tbltwo_easting
tbltwo_northing

Table 1 and Table 2 does have other fields but the ones I have listed are
the key ones to explain my problem. And that problem is that table 2
contains dirty data and table 1 the good data. For both tables the CustID is
unique and there are no CustID's in table 2 that are in table 1.

I am trying to extract from table 1 good data where the easting and northing
are close so I end up with a new table returning values from table 1 and
values from table 2. That way I can then re-populate later on the results
into table 1.

The query parameters as per design view

FIELD...........Expr1: Abs(tblone_easting - tbltwo_easting)
FIELD...........Expr2: Abs(tblone_northing - tbltwo_northing)

For each of these 2 fields I have a CRITERIA of "<10".

Understandably the query will take a while, upto now its been running for 9
hrs (on my spare PC at work). And what I have realised while testing on my
PC at home is that when I eventually get results I cannot export the results
without the query re-running.

So therefore;
Q1: Is there a quicker way of querying "tbltwo" against "tblone" as per my
query parameters above.
Q2: If I am lucky enough to return to work and find I have results how can I
export those results without the query re-running.

many many thanks

Macroman


You didn't show a query. I am wondering if somehow you got a Cartesian
Join going or something else wrong.

You should be able to create a query something like
Select CustID, "T1" As Table, easting, northing _
From Table1
Where Abs(tblone_easting - tbltwo_easting) < 10
Save it as query1
Now run it.
How long does it take to compute?

You should be able to write another query
Select CustID, "T2" As Table, easting, northing _
From Table2
Where Abs(tblone_easting - tbltwo_easting) < 10
Save it as query2
Now run it.
How long does it take to compute?

Now you can create another query that Unions them
Select Query1.* From Query1
UNION ALL
Select Query2.* From Query2
and save it as Query3
Now run it.

It shouldn't take longer than running the two queries by themselves.

Mar 21 '06 #3
"Macroman" <pd*********@btinternet.com> wrote in
news:dv**********@nwrdmz02.dmz.ncs.ea.ibs-infra.bt.com:
MS Access XP, running on Win XP, Processor 2.4Ghz , 512Mb RAM,
40Gb Hard drive

Table 1 has 167,000 records and contains the following fields
tblone_custID
tblone_easting
tblone_northing

Table 2 has 423,000 records and contains the following fields
tbltwo_custID
tbltwo_easting
tbltwo_northing

Table 1 and Table 2 does have other fields but the ones I have
listed are the key ones to explain my problem. And that
problem is that table 2 contains dirty data and table 1 the
good data. For both tables the CustID is unique and there are
no CustID's in table 2 that are in table 1.

I am trying to extract from table 1 good data where the
easting and northing are close so I end up with a new table
returning values from table 1 and values from table 2. That
way I can then re-populate later on the results into table 1.

The query parameters as per design view

FIELD...........Expr1: Abs(tblone_easting - tbltwo_easting)
FIELD...........Expr2: Abs(tblone_northing - tbltwo_northing)

For each of these 2 fields I have a CRITERIA of "<10".

Understandably the query will take a while, upto now its been
running for 9 hrs (on my spare PC at work). And what I have
realised while testing on my PC at home is that when I
eventually get results I cannot export the results without the
query re-running.

So therefore;
Q1: Is there a quicker way of querying "tbltwo" against
"tblone" as per my query parameters above.
Q2: If I am lucky enough to return to work and find I have
results how can I export those results without the query
re-running.

many many thanks

Macroman

You are generating a product recordset of 167,000 x 423,000
records to be tested. That's going to take a long time.

The next time, generate a query on table one that calculates min
and max limits for your two fields. Use that query to test table
two values as between the limits in the query. This is still
slow, but faster than your way.

If you get a result set, try just copying the results to the
clipboard, if there aren't too many rows. {Ctrl-A}{Ctrl-C}, then
paste into your desired table.

saves re-running.
--
Bob Quintal

PA is y I've altered my email address.
Mar 21 '06 #4
"Macroman" <pd*********@btinternet.com> wrote in
news:dv**********@nwrdmz02.dmz.ncs.ea.ibs-infra.bt.com:
MS Access XP, running on Win XP, Processor 2.4Ghz , 512Mb RAM, 40Gb
Hard drive

Table 1 has 167,000 records and contains the following fields
tblone_custID
tblone_easting
tblone_northing

Table 2 has 423,000 records and contains the following fields
tbltwo_custID
tbltwo_easting
tbltwo_northing

Table 1 and Table 2 does have other fields but the ones I have listed
are the key ones to explain my problem. And that problem is that table
2 contains dirty data and table 1 the good data. For both tables the
CustID is unique and there are no CustID's in table 2 that are in
table 1.

I am trying to extract from table 1 good data where the easting and
northing are close so I end up with a new table returning values from
table 1 and values from table 2. That way I can then re-populate later
on the results into table 1.

The query parameters as per design view

FIELD...........Expr1: Abs(tblone_easting - tbltwo_easting)
FIELD...........Expr2: Abs(tblone_northing - tbltwo_northing)

For each of these 2 fields I have a CRITERIA of "<10".

So therefore;
Q1: Is there a quicker way of querying "tbltwo" against "tblone" as
per my query parameters above.
Q2: If I am lucky enough to return to work and find I have results how
can I export those results without the query re-running.

many many thanks

Macroman


Create indexes on the custID fields in both tables...

Then...

select t1.custid, t1.easting, t1.northing, t2.easting, t2.northing
from table1 as t1 inner join table2 as t2 on t1.custid = t2.custid
where ((t1.easting - t2.easting) between -10 and 10)
and ((t2.northing - t2.northing) between -10 and 10)

part of this is to avoid using the call to the VBA function ABS. Creating
the indexes should increase the speed of the query a bit, too. There is
not much point in indexing the easting and northing fields.

If the query is running right for you, then make a copy of the query and
make it into a "make table" query. Then export this new table instead.
and you only have to run the query once...

Mar 30 '06 #5

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

Similar topics

4
by: DBNovice | last post by:
I have a database that keeps records on the issue and failure of an item. Currently, the database is poorly desisned; therefore I'm performing queries to break the data into normalized tables and...
6
by: Muharram Mansoorizadeh | last post by:
Hi there, I've a table with 18 millions of recordes shaped like this : Code nvarchar(80) , State int , school int , class int , Term nvarchar(80) The following query takes too long to run ( more...
4
by: ED | last post by:
I am attempting to to write a query that has a numerous nested IIf statements. The problem that I am having is that it is to long of a query to be built in design mode and when I build it in sql...
3
by: Jamie Pittman via AccessMonster.com | last post by:
I am having trouble bellow wit this query. I have the total regular hours and the overtime. The problem is that if it is 8 hours and under, I need it to show as regular hours. Any thoughts? ...
5
by: ????? | last post by:
I have an access query which gets data from a number of different tables. Although the tables have primary key fields, the order in which the records are returned means that none of these are in...
30
by: Noob | last post by:
ftp://ukcassassin:winston@www.ukcassassin.pwp.blueyonder.co.uk/htdocs/Diary%20Form.bmp Hi all I will appologise in advance for my lack of knowledge of access and its working as i am quite new to...
3
blyxx86
by: blyxx86 | last post by:
I have created a form that keeps record of a few queries that are ran. One set of queries takes 30 minutes to pull the information. The other takes about 6 minutes. I managed to use two...
1
by: andet | last post by:
A simple query, doing an inner join to one table and an outer join to 2 other tables with one variable input is taking forever. I did some research and I saw that access had created 3 actual queries...
2
by: existential.philosophy | last post by:
This is a new problem for me: I have some queries that open very slowly in design view. My benchmark query takes about 20 minutes to open in design view. That same query takes about 20 minutes...
7
by: Yesurbius | last post by:
I am receiving the following error when attempting to run my query. In my mind - this error should not be happening - its a straight-forward query with a subquery. I am using Access 2003 with all...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
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
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,...
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
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,...

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.