Solved

How to speed up a MS SQL Pivot view

Posted on 2012-04-03
7
801 Views
Last Modified: 2012-04-18
Hello,
I have an Access / SQL server application which uses a MS Sql view populate an Access front-end form at runtime.  Although the view executes quickly in SSMS, it takes a long time to populate the form.  I'm trying to think of alternative ways to populate that form using the data displayed by the view.  I'm thinking of using a table to hold the pivot view data and making that table as the data source for the unbound form.  This is a multiuser environment and I need to figure out a way to load the form faster.  I'm looking for advice on the best approach to take.  The record set is about 20,000 records.  I'd appreciate any ideas.
0
Comment
Question by:chtullu135
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
7 Comments
 
LVL 6

Expert Comment

by:Peter Kiprop
ID: 37804959
Hi chtullu135,

which control do you have on the form? How are you populating currently using a loop or what?

Regards,
Pthepebble.
0
 

Author Comment

by:chtullu135
ID: 37806361
I am populating the form via a view in the following manner

Private Sub Form_Load()
Const SUBNAME = "Form_Load"
'On Error GoTo Err_Handler

    ClearComboBoxes
    'PopulateMainComboBoxes
    'LoadRetrieve
   
    gstrFilePath = ""
    strWhereClause = ""
    strRecordSource = "SELECT dbo_vwPivotedReviewsRevised.USI, dbo_vwPivotedReviewsRevised.WorkStream, dbo_vwPivotedReviewsRevised.GFP, " & _
                       "dbo_vwPivotedReviewsRevised.Review1 , dbo_vwPivotedReviewsRevised.Status1, " & _
                       "dbo_vwPivotedReviewsRevised.Review2 , dbo_vwPivotedReviewsRevised.Status2, " & _
                       "dbo_vwPivotedReviewsRevised.Review3 , dbo_vwPivotedReviewsRevised.Status3, " & _
                       "dbo_vwPivotedReviewsRevised.Review4 , dbo_vwPivotedReviewsRevised.Status4, " & _
                       "dbo_vwPivotedReviewsRevised.Review5 , dbo_vwPivotedReviewsRevised.Status5, " & _
                       "dbo_vwPivotedReviewsRevised.Review6 , dbo_vwPivotedReviewsRevised.Status6, " & _
                       "dbo_vwPivotedReviewsRevised.Review7 , dbo_vwPivotedReviewsRevised.Status7, " & _
                       "dbo_vwPivotedReviewsRevised.Review8 , dbo_vwPivotedReviewsRevised.Status8 " & _
                       "FROM dbo_vwPivotedReviewsRevised "
                       
    strClearFilterSource = strRecordSource
                       
    Me.RecordSource = strRecordSource
    'Me.cmbFilterByGFP.RowSource = "SELECT DISTINCT dbo_vwPivotedReviewsRevised.GFP FROM dbo_vwPivotedReviewsRevised ORDER BY dbo_vwPivotedReviewsRevised.GFP"


'Exit_Sub:
'    Exit Sub
'
'Err_Handler:
'    MsgBox "Module Name: " & MODULENAME & vbCrLf & _
'            "Procedure: " & SUBNAME & vbCrLf & _
'            "Error Number: " & Err.Number & vbTab & "Error Description: " & Err.Description
'    Resume Exit_Sub
   
End Sub
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37806494
<it takes a long time to populate the form.>
Please define this in Chronological terms please...
"A Long Time" is a very vague term...

Note that the time this takes, just may be "what it is"
1. You are pulling 20,000 records over the wire, so the network may be a limiting factor here...

2. You are creating a Pivot. Pivots in general take time to create as they must aggregate the data.
The more records, the more complex the aggregation, the more fields you are using, ...the "slower" the performance.

3. Also you have a "mystery" call in there: ClearComboBoxes
...it is not clear what this is...

4. You are not declaring your variables. (strWhereClause, strRecordSource, strClearFilterSource )
This forces them all to me Variants which takes longer to process...
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37808086
RichardRost,

Just a note...
EE does not really allow a Link to a/your site in your signature
This info can be in your profile though...

;-)

jeffCoachman
0
 

Accepted Solution

by:
chtullu135 earned 0 total points
ID: 37814975
I found what the bottleneck was.  Basically I redid all the underlying views so that I only retrieved the data I needed.  I also was making multiple calls to the backend in order to populated multiple and similar comboboxes.  I simplified that stored procedure and used it to populate all the similar comboboxes.  Now the form loads in about 90 seconds, which is much better than the 10 minutes it was taking
0
 

Author Closing Comment

by:chtullu135
ID: 37859736
I found the problem by myself
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question