Results 1 to 13 of 13
  1. #1
    lburch is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2020
    Posts
    12

    Query takes 30 sec

    Hi i have an access DB with 2million records
    I have a query that looks up 6 conditions with all needing to be true.



    Is 30sec an average time to return results.
    I was hoping for 5sec. I paid someone to create, and am a bit disappointed it takes 30 sec.

    I have tried all quick fix options
    compact
    turning off autofill etc

  2. #2
    jojowhite's Avatar
    jojowhite is online now Competent Performer
    Windows 11 Access 2021
    Join Date
    Jan 2025
    Posts
    433
    care to share/post the SQL string.
    maybe someone here with good eye sight can make the query better
    and reduce the waiting time.

  3. #3
    lburch is offline Novice
    Windows 11 Office 365
    Join Date
    Feb 2020
    Posts
    12
    would be happy too, just not sure how sorry

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Copy and paste it between code tags using the # icon.
    Are all the fields being searched indexed?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    lburch is offline Novice
    Windows 11 Office 365
    Join Date
    Feb 2020
    Posts
    12
    ok will post


  6. #6
    lburch is offline Novice
    Windows 11 Office 365
    Join Date
    Feb 2020
    Posts
    12
    Code:
    TRANSFORMSum(Qry_Race_OddsCateg_Count.[Number of Runners]) AS [SumOfNumber of Runners]SELECT Qry_Race_OddsCateg_Count.Race_ID, Sum(Qry_Race_OddsCateg_Count.[Number of Runners]) AS [Total Of Number of Runners]
    FROM Qry_Race_OddsCateg_Count
    GROUP BY Qry_Race_OddsCateg_Count.Race_ID
    PIVOT Qry_Race_OddsCateg_Count.OddsCateg;
    
    

  7. #7
    lburch is offline Novice
    Windows 11 Office 365
    Join Date
    Feb 2020
    Posts
    12
    sorry doubled up

  8. #8
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Need to show Qry_Race_OddsCateg_Count as that is where the data is organized?

    How long does that take to run?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  9. #9
    lburch is offline Novice
    Windows 11 Office 365
    Join Date
    Feb 2020
    Posts
    12
    Code:
    SELECT Qry_Runners_FullList.Race_ID, Qry_Runners_FullList.OddsCateg, Count(Qry_Runners_FullList.Runner_ID) AS [Number of Runners]FROM Qry_Runners_FullList LEFT JOIN Qry_Race_TotalRunners_Count ON Qry_Runners_FullList.Race_ID = Qry_Race_TotalRunners_Count.Race_ID
    WHERE (((Qry_Race_TotalRunners_Count.[Total Runners]) Between 
    Eval("[forms]![frm_Main]![NavigationSubform].form![vMinRunners]") And 
    Eval("[forms]![frm_Main]![NavigationSubform].form![vMaxRunners]")))
    
    GROUPBY Qry_Runners_FullList.Race_ID, Qry_Runners_FullList.OddsCateg;

  10. #10
    jojowhite's Avatar
    jojowhite is online now Competent Performer
    Windows 11 Access 2021
    Join Date
    Jan 2025
    Posts
    433
    i haven't tested this:

    Code:
    TRANSFORM Count(Qry_Runners_FullList.Runner_ID) AS [Number of Runners] 
    SELECT Qry_Runners_FullList.Race_ID 
    FROM Qry_Runners_FullList LEFT JOIN Qry_Race_TotalRunners_Count ON Qry_Runners_FullList.Race_ID = Qry_Race_TotalRunners_Count.Race_ID
    WHERE (((Qry_Race_TotalRunners_Count.[Total Runners]) Between 
    Eval("[forms]![frm_Main]![NavigationSubform].form![vMinRunners]") And 
    Eval("[forms]![frm_Main]![NavigationSubform].form![vMaxRunners]"))) 
    GROUP BY Qry_Runners_FullList.Race_ID 
    PIVOT Qry_Runners_FullList.OddsCateg;

  11. #11
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Not sure you need the Eval?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  12. #12
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,932
    you don't - but you would then need to declare the form references as parameters since this is used as a Xtab query

    think we also need to see the sql to the Qry_Race_TotalRunners_Count query since you should be applying where parameters earlier in the chain i.e.

    Between
    Eval("[forms]![frm_Main]![NavigationSubform].form![vMinRunners]")
    And
    Eval("[forms]![frm_Main]![NavigationSubform].form![vMaxRunners]")

    should be in the earlier query


  13. #13
    madpiet is offline Expert
    Windows 10 Office 365
    Join Date
    Feb 2023
    Posts
    565
    But did you try indexing the join and filter columns? The rest won't do anything. If you want it to be fast, you have to fix that parts that are making it slow.
    Oh, and without the SQL Statement, it's impossible to tell what to fix.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Format field for Min:Sec.000
    By JimO in forum Access
    Replies: 6
    Last Post: 03-12-2016, 08:06 PM
  2. Access Takes my Query and Alters it!
    By dso808 in forum Queries
    Replies: 2
    Last Post: 10-01-2010, 03:45 PM
  3. Time as min:sec
    By thekruser in forum Programming
    Replies: 6
    Last Post: 09-15-2010, 09:34 AM
  4. Replies: 1
    Last Post: 06-30-2010, 12:47 PM
  5. Query Design View Takes a Long Time to Open
    By jackthedog in forum Queries
    Replies: 0
    Last Post: 12-22-2009, 03:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums