Page 2 of 2 FirstFirst 12
Results 16 to 19 of 19
  1. #16
    madpiet is offline Expert
    Windows 10 Office 365
    Join Date
    Feb 2023
    Posts
    566
    Code:
    SET ANSI_NULLS ONGO
    
    
    SET QUOTED_IDENTIFIER ON
    GO
    /*
    Created by Minty - 30/07/2024
    Simple example View 
    Minor mods: Pieter - 31/07/2024
    */
    
    
    CREATE VIEW [dbo].[vw_My_First View]
    
    
    AS
    
    
    SELECT SR.State_Name, 
        SR.Labels,
        SR.Letter,
        SR.Summary_of_Changes, 
        SR.EPA_Stamped_Documents, 
        SR.EPA_Notification_Documents,
        SR.SDS,
        SR.Registration_Comments,
        SSA.Submision_Email, 
        SSA.Online_Portal 
    FROM 72_tbl_State_Registration_Requirements SR 
    LEFT OUTER JOIN 72_tbl_State_Contacts SC ON SR.State_Name = SC.State_Name
    LEFT OUTER JOIN 72_tbl_State_Submission_Access SSA ON SC.State_Name = SSA.State
    WHERE SC.Registration_Type Like '%Revisions%' AND SR.Registration_Type ='Revisions/Supplementals';
    Unless I'm completely losing my mind, you can't use ORDER BY in a view unless you use TOP...



    What happens if you turn the query into a Pass-through query?
    Last edited by madpiet; 07-31-2024 at 05:35 PM.

  2. #17
    Join Date
    Jun 2010
    Location
    Belgium
    Posts
    1,180
    In reply to the question #13:

    "I executed the query as instructed. Then what?"

    If you executed the query with the option "Include actual query plan" you should get a query plan similar to the included picture. If there are missing indexes for the plan they will be stated in green, right click these green lines to see the proposed index.
    If not, in the plan you can exactly see how many seconds each step takes (read from right to left) and where you can improve the query.

    As I already stated: creating a view won't help the speed. When executing the engine just performs the query as it would do if you start it manually. In a view "ORDER BY" makes no sense, unless you include a TOP statement, for example to get the top 100 newest entries ordered by creation date DESC.



    Attached Thumbnails Attached Thumbnails QueryPlanExample.jpg  

  3. #18
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,159
    Quote Originally Posted by madpiet View Post
    Unless I'm completely losing my mind, you can't use ORDER BY in a view unless you use TOP...

    What happens if you turn the query into a Pass-through query?
    The Order By clause will become irrelevant as the report does the sorting separately.
    I suspect the real issue is Access manipulating the data on the fly for the Report, which is causing it to re-query the server multiple times.

    Using the view as a linked table (you can connect to it just like a table) try using that as source for your report.
    If, as suggested, that doesn't improve matters, just for experiments sake, use the view to make a local temp table in Access then run the report from that local table.

    You never did answer the question about how many rows of data are involved?
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  4. #19
    madpiet is offline Expert
    Windows 10 Office 365
    Join Date
    Feb 2023
    Posts
    566
    Didn't think of that part... dumping the data to a temp table. Gets my vote!

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Slow Report Export to rtf file
    By cowannbell in forum Import/Export Data
    Replies: 5
    Last Post: 10-27-2022, 03:46 AM
  2. Slow day
    By davegri in forum Misc
    Replies: 14
    Last Post: 05-15-2021, 06:48 AM
  3. Replies: 9
    Last Post: 03-07-2019, 06:23 PM
  4. Queries running painfully slow~split database
    By sinisterfrog in forum Access
    Replies: 13
    Last Post: 07-23-2018, 07:38 PM
  5. Replies: 2
    Last Post: 03-29-2012, 08:49 AM

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