Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Query slowed up

Query slowed up

Scheduled Pinned Locked Moved Database
databaseannouncement
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jishbalan
    wrote on last edited by
    #1

    rs1.Open "SELECT Count(1)FROM (SELECT DISTINCT mt1.TestCaseName, mt1.TestScriptName, " & _ "mt1.FinalStatus FROM (Metrics_TestCases " & _ "AS mt1 INNER JOIN MaxScriptQuery as mt2 ON( mt1.TestCaseName = mt2.TestCaseName And " & _ mt1.TestScriptName = mt2.TestScriptName And mt1.ReleaseVersion = mt2.ReleaseVersion and " & _ "mt1.TestScriptID = mt2.maxTestScriptID) ) INNER JOIN Release_chart as tr ON mt1.ReleaseVersion = tr.ReleaseVersion) " & _ " ", oConnection, adOpenStatic, adLockReadOnly This is the query i used to get some data from access table. MaxScriptQuery is a inner query i used to join . MaxScriptQuery - SELECT DISTINCT TestCaseName, TestScriptName, ReleaseVersion, MAX(TestScriptID) AS MaxTestScriptID FROM Metrics_TestCases GROUP BY TestCaseName, TestScriptName, ReleaseVersion; This query worked fine some week before. But to my surprise now the same query with same set of data is taking too much time. I dont know why the query is suddenly slowed up. CPU usage is also very high while running this query

    M 1 Reply Last reply
    0
    • J jishbalan

      rs1.Open "SELECT Count(1)FROM (SELECT DISTINCT mt1.TestCaseName, mt1.TestScriptName, " & _ "mt1.FinalStatus FROM (Metrics_TestCases " & _ "AS mt1 INNER JOIN MaxScriptQuery as mt2 ON( mt1.TestCaseName = mt2.TestCaseName And " & _ mt1.TestScriptName = mt2.TestScriptName And mt1.ReleaseVersion = mt2.ReleaseVersion and " & _ "mt1.TestScriptID = mt2.maxTestScriptID) ) INNER JOIN Release_chart as tr ON mt1.ReleaseVersion = tr.ReleaseVersion) " & _ " ", oConnection, adOpenStatic, adLockReadOnly This is the query i used to get some data from access table. MaxScriptQuery is a inner query i used to join . MaxScriptQuery - SELECT DISTINCT TestCaseName, TestScriptName, ReleaseVersion, MAX(TestScriptID) AS MaxTestScriptID FROM Metrics_TestCases GROUP BY TestCaseName, TestScriptName, ReleaseVersion; This query worked fine some week before. But to my surprise now the same query with same set of data is taking too much time. I dont know why the query is suddenly slowed up. CPU usage is also very high while running this query

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      Access is a dog - I would compress & repair the database and see if it improves the response. Look into adding any required indexes.

      J 1 Reply Last reply
      0
      • M Mycroft Holmes

        Access is a dog - I would compress & repair the database and see if it improves the response. Look into adding any required indexes.

        J Offline
        J Offline
        jishbalan
        wrote on last edited by
        #3

        Thanks for your reply Holmes. But dont know how to compact and repair without exiting the application in VBA. Normally the compact and repair is used while exiting the application . How to apply it for a running code?

        M D 2 Replies Last reply
        0
        • J jishbalan

          Thanks for your reply Holmes. But dont know how to compact and repair without exiting the application in VBA. Normally the compact and repair is used while exiting the application . How to apply it for a running code?

          M Offline
          M Offline
          mnatarajakumaran
          wrote on last edited by
          #4

          Hi, Don't use Distinct key word its will reduce the performance. Without distinct also given the same result because you are using group by class. So no need distinct key word. Just remove and check it.

          1 Reply Last reply
          0
          • J jishbalan

            Thanks for your reply Holmes. But dont know how to compact and repair without exiting the application in VBA. Normally the compact and repair is used while exiting the application . How to apply it for a running code?

            D Offline
            D Offline
            David Skelly
            wrote on last edited by
            #5

            Well, I posted an entry explaining this yesterday but it seems to have disappeared. Not sure what happened there. I was having a few problems accessing the site yesterday. I can't be bothered writing it all again, but basically you cannot compact a database while it is open. If you want to run the compact from code, you must run it from a different database. Then you can use DBEngine.CompactDatabase, making sure that the data file is closed and is not in use before you do the compact.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups