How to fix Access Query that is running very slow?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • David Goldstraw
    New Member
    • Jan 2011
    • 6

    How to fix Access Query that is running very slow?

    I have two databases and I want to automate a process to find duplicates. I originally linked the table from one into the other but I have now gone down the route of importing the table from one db into the main one because it was running too slow.

    Now I have imported the table I am still getting a very slow response from the query. I have tried numerous routes i.e. update, make table and even select and it is till slow. The query I am running is (will example update mode)

    UPDATE tbmaindata SET tbmaindata.InCh ineseDB = "Y"
    WHERE left(tbmaindata .add1,6) & tbmaindata.post code = left(tbmaindata 1.add1,6) & tbmaindata1.pos tcode;


    This query no matter how I seem to do it whether it be like the example or using various queries to get the result is really slow and this process need to be automated every time the db is opened. This would take forever.

    All I want to do is confirm the existence of certain records in another db. I was going to achieve this by using a macro to import the table, run query to update a column and then delete the imported table.

    Can someone please help me speed this process up or point out if there is something amiss with my query.

    Thanks in advance

    Dave
    Last edited by David Goldstraw; Jan 25 '11, 10:08 AM. Reason: Spelling :o(
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    #2
    It's the string functions and string comparison.
    The fact string manipulation is done across two databases won't help either.
    Can the WHERE clause compare some numerical field instead of postcode?
    If not could you add numerical comparison fields?
    All I want to do is confirm the existence of certain records in another db
    If this is the case, it is better to JOIN the two tables ON a suitable field, and using
    WHERE field IS NOT NULL

    Comment

    • David Goldstraw
      New Member
      • Jan 2011
      • 6

      #3
      Hi Thanks for your reply, I have actually imported the table in to my main db and it is still slow. I will try your suggestion by linking the tables

      Comment

      • TheSmileyCoder
        Recognized Expert Moderator Top Contributor
        • Dec 2009
        • 2322

        #4
        Just to have something to relate to, how many records are present in each database, and how long is it taking?

        For some things/users, 3 seconds is long time, and sometimes 3 minutes is a long time, so you need to be a bit more accurate :P

        Other then that "Code Green" is right, the string Manipulations are slowing you down.

        Comment

        • David Goldstraw
          New Member
          • Jan 2011
          • 6

          #5
          There are 13,026 in one and 1,505 in the other. it was taking 15+ mins.

          Comment

          • David Goldstraw
            New Member
            • Jan 2011
            • 6

            #6
            Hi Code Green,
            You certainly pointed me in the right direction. I have used the following which appears to give me my required result.

            SELECT tbmaindata.URN, tbmaindata.Add1 , tbmaindata.post code, tbMainData1.URN , tbMainData1.Add 1, tbMainData1.pos tcode
            FROM tbmaindata INNER JOIN tbMainData1 ON (tbmaindata.pos tcode) = tbMainData1.pos tcode AND (left(tbmaindat a.Add1,6)) = left(tbMainData 1.Add1,6);


            Thanks for your help

            Dave

            Comment

            • Rabbit
              Recognized Expert MVP
              • Jan 2007
              • 12517

              #7
              Indexes on postcode and Add wouldn't hurt either.

              Comment

              • David Goldstraw
                New Member
                • Jan 2011
                • 6

                #8
                I had already indexed them but it didn't help, that was my first thought. The db is sat on a server which doesn't help. It seems to be working a treat now anyway so thanks eveyone

                Comment

                Working...