Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Need help optimizing a pivot view

Posted on 2012-04-05
2
Medium Priority
?
281 Views
Last Modified: 2012-04-05
Hello,

I have the following view that's taking 40 seconds to execute.  I've been trying to speed it up and am having no lock.  I am using MS SQL server 2005

SELECT p1.USI,
      MAX([Review1]) AS [Review1],    
      MAX([Review2]) AS [Review2],  
      MAX([Review3]) AS [Review3],  
      MAX([Review4]) AS [Review4],
      MAX([Review5]) AS [Review5],    
      MAX([Review6]) AS [Review6],  
      MAX([Review7]) AS [Review7],  
      MAX([Review8]) AS [Review8]
FROM (
SELECT      USI, Review, 'Review'+CONVERT(VARCHAR(2),rn) ReviewPvtCol            
FROM      (SELECT USI, Review,             
                  ROW_NUMBER() OVER (PARTITION BY USI ORDER BY Review) rn
             FROM  dbo.vwViewAllForPivot) AS SourceTable
) p
PIVOT
(
max(Review)
FOR ReviewPvtCol IN ([Review1], [Review2], [Review3], [Review4], [Review5], [Review6], [Review7], [Review8])
) AS P1

GROUP BY P1.USI
GO
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
2 Comments
 
LVL 23

Expert Comment

by:wdosanjos
ID: 37812922
How many rows does dbo.vwViewAllForPivot have?
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 2000 total points
ID: 37813201
*Again*, this may just be "What it is"...

This is basically the same Q as this one:
http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/Q_27661444.html
If not, then please explain the difference...?
...otherwise this issue need to be addressed in the original question...

Make sense?

JeffCoachman
0

Featured Post

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

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

What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

636 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