Actually, there is a certain time delay in the newsgroup and if you are
urgent and the problem is critical, it is not suitable to resolve the issue
through the newsgroup.
Of course. This was not a mission-critical piece of functionality, and we
could have provided a workaround, so it wasn't too urgent.
And as I said in my original message, opening a support call would be very
difficult for me. So I want to avoid it if possible!
Based on your information, you view covers different tables in one
database, when execute in the Query Analyzer on the SQL Server machine
'select ... from the view_name1 where...' it is fast. When in the ADP, a by
using the Report wizard to create a report on the 'select ... from the
view_name1 where...', it is fast, right?
Yes, that is correct.
In my last reply, the second step is means:
Since the row source of the combo box is 'select ... from the view_name1
where...', in your ADP, open view_name1, will it hang? Then could you
create a new view, named 'view_name2'. The definition of it would be:
'select ... from view_name1 where ...', same as the row source of the combo
box. Then, save and open the 'view_name2', how long it will take for
returnning the result set that you want to show in the combo box? Will it
hang?
The original view ("view_name1") will hang if I open it directly in the ADP.
I created a new "wrapper" view ("view_name2"), which is the same as the row
source of the combo box. It behaves just like "view_name1": It runs very
fast in Query Analyzer or as the data sourcew of a report. If I try to open
"view_name2" directly, or use it as the row source of a combo box, it hangs.
I tested that on my side, and use the profiler to catch the T-SQL:
BatchCompleted, the T-SQL I caught is just the report and the combo box
based on. You could only see the execution plan in the Query Analyzer by
press Ctrl+L after you run the query in the Query Analyzer.
Ctrl+L will just give you an estimated execution plan. Try using Ctrl+K (or
Query --> Show Execution Plan) in Query Analyzer, then running it, to get
the "real" execution plan, which is sometimes different.
No matter what
the view I use, since the data accessible through a view is not stored in
the database as a distinct object. What is stored in the database is a
SELECT statement. If the query for the report and the combo box is the
same, t hen the execution is the same because the run the same select
statements. In my testing it is the same. So, could you double-check it?
I know this should be the case. But I had Profiler display execution plans
(in the "Events" tab, add Performance --> Execution Plan) and the Execution
Tree shown differs. I don't know why the combo box triggers a different
execution plan, I can hardly believe my eyes, it doesn't make any sense to
me. But here is the Execution Tree after running the query in Query
Analyzer (I know it will not mean much, I just want to show they are
different):
Compute Scalar(DEFINE
[Expr1026]=If ([pimParticipant].[CaseNum]<>NULL) then
[pimParticipant].[CaseNum] else ''+If ('
'+[pimParticipant].[GeneticCode]<>NULL) then ('
'+[pimParticipant].[GeneticCode]) else ''))
|--Hash Match(Right Outer Join,
HASH
[demAnswerTypeOptions].[AnswerTypeID],
[demOptions].[OptionValue])=([demForm].[FormInstance_AnswerTypeID],
[demInterviewForm].[FormInstanceID]),
RESIDUAL
[demForm].[FormInstance_AnswerTypeID]=[demAnswerTypeOptions].[Answ
erTypeID] AND
[demInterviewForm].[FormInstanceID]=[demOptions].[OptionValue]))
|--Hash Match(Inner Join,
HASH
[demOptions].[OptionId])=([demAnswerTypeOptions].[OptionID]))
| |--Clustered Index
Scan(OBJECT
[PPDM].[dbo].[demOptions].[PK__demOptions__09A971A2]))
| |--Clustered Index
Scan(OBJECT
[PPDM].[dbo].[demAnswerTypeOptions].[PK_demAnswerTypeOptions]))
|--Merge Join(Inner Join, MANY-TO-MANY
MERGE
[schEntry].[SchedID])=([demInterviewForm].[SchedID]),
RESIDUAL
[demInterviewForm].[SchedID]=[schEntry].[SchedID]))
|--Sort(ORDER BY
[schEntry].[SchedID] ASC))
| |--Compute
Scalar(DEFINE
[schEntry].[SchedID]='@SiteID='+ltrim(str(Convert(dbo.schEntr
y.[SiteID]), NULL,
NULL))+',@ProbandId='+ltrim(str(Convert(dbo.schEntry.[ProbandId]), NULL,
NULL))+',@StudyID='+ltrim(str(Convert(dbo.schEntry.[StudyID]), NULL,
NULL))+',@PId='+ltrim(str(Convert(dbo.schEntry.[PId]), NULL,
NULL))+',@ProtId='+ltrim(str(Convert(dbo.schEntry.[ProtId]), NULL,
NULL))+',@ProcID='+ltrim(str(Convert(dbo.schEntry.[ProcID]), NULL,
NULL))+',@InterviewId='+ltrim(str(Convert(dbo.schEntry.[InterviewId]), NULL,
NULL))))
| |--Index
Scan(OBJECT
[PPDM].[dbo].[schEntry].[XIFschEntry_PIDStudySiteProc]))
|--Sort(ORDER BY
[demInterviewForm].[SchedID] ASC))
|--Nested Loops(Inner Join, OUTER
REFERENCES
[demInterviewForm].[PId]) WITH PREFETCH)
|--Nested Loops(Inner Join, OUTER
REFERENCES
[demInterviewForm].[TargetPId]) WITH PREFETCH)
| |--Sort(ORDER BY
[demInterviewForm].[TargetPId]
ASC))
| | |--Nested Loops(Inner Join, OUTER
REFERENCES
[demInterviewForm].[ProbandId]) WITH PREFETCH)
| | |--Nested Loops(Inner Join, OUTER
REFERENCES
[demInterviewForm].[ProcID]))
| | | |--Nested Loops(Inner Join, OUTER
REFERENCES
[demInterviewForm].[ProtId]))
| | | | |--Hash Match(Inner Join,
HASH
[admStudy].[StudyID])=([demInterviewForm].[StudyID]))
| | | | | |--Clustered Index
Scan(OBJECT
[PPDM].[dbo].[admStudy].[PK__admStudy__53640638]))
| | | | | |--Merge Join(Inner
Join, MERGE
[admSite].[SiteId])=([demInterviewForm].[SiteId]),
RESIDUAL
[demInterviewForm].[SiteId]=[admSite].[SiteId]))
| | | | | |--Nested
Loops(Inner Join)
| | | | | | |--Clustered
Index Seek(OBJECT
[PPDM].[dbo].[demForm].[PK_demForm]),
SEEK
[demForm].[FormID]=Convert([@1])) ORDERED FORWARD)
| | | | | | |--Clustered
Index Scan(OBJECT
[PPDM].[dbo].[admSite].[PK__admSite__526FE1FF]), ORDERED
FORWARD)
| | | | | |--Compute
Scalar(DEFINE
[demInterviewForm].[SchedID]='@SiteID='+ltrim(str(Convert([de
mInterviewForm].[SiteId]), NULL,
NULL))+',@ProbandId='+ltrim(str(Convert([demInterviewForm].[ProbandId]),
NULL, NULL))+',@StudyID='+ltrim(str(Convert([demInterviewForm].[StudyID]),
NULL, NULL))+',@PId='+ltrim(str(Convert([demInterviewForm].[PId]), NULL,
NULL))+',@ProtId='+ltrim(str(Convert([demInterviewForm].[ProtId]), NULL,
NULL))+',@ProcID='+ltrim(str(Convert([demInterviewForm].[ProcID]), NULL,
NULL))+',@InterviewId='+ltrim(str(Convert(dbo.demInterviewForm.[InterviewId]
), NULL, NULL))))
| | | | | |--Clustered
Index
Scan(OBJECT
[PPDM].[dbo].[demInterviewForm].[PK__demInterviewForm__4CA06362
]), WHERE
[demInterviewForm].[FormID]=Convert([@1]) AND
[demInterviewForm].[StatusFlag]='N') ORDERED FORWARD)
| | | | |--Clustered Index
Seek(OBJECT
[PPDM].[dbo].[admProtocol].[PK__admProtocol__517BBDC6]),
SEEK
[admProtocol].[ProtId]=[demInterviewForm].[ProtId]) ORDERED FORWARD)
| | | |--Clustered Index
Seek(OBJECT
[PPDM].[dbo].[admProcedure].[PK__admProcedure__5087998D]),
SEEK
[admProcedure].[ProcID]=[demInterviewForm].[ProcID]) ORDERED FORWARD)
| | |--Index
Seek(OBJECT
[PPDM].[dbo].[pimParticipant].[XIFpimParticipant_PID_PPDMPsychE
valDate]), SEEK
[pimParticipant].[PId]=[demInterviewForm].[ProbandId])
ORDERED FORWARD)
| |--Clustered Index
Seek(OBJECT
[PPDM].[dbo].[pimParticipant].[PK_pimParticipant]),
SEEK
[pimParticipant].[PId]=[demInterviewForm].[TargetPId]) ORDERED
FORWARD)
|--Index
Seek(OBJECT
[PPDM].[dbo].[pimParticipant].[XIFpimParticipant_PID_PPDMPsychE
valDate]), SEEK
[pimParticipant].[PId]=[demInterviewForm].[PId]) ORDERED
FORWARD)
And here is the Execution Tree for the *EXACT SAME QUERY*, but run as the
row source of a combo box:
Compute Scalar(DEFINE
[Expr1026]=If ([pimParticipant].[CaseNum]<>NULL) then
[pimParticipant].[CaseNum] else ''+If ('
'+[pimParticipant].[GeneticCode]<>NULL) then ('
'+[pimParticipant].[GeneticCode]) else ''))
|--Nested Loops(Left Outer Join, OUTER
REFERENCES
[demInterviewForm].[FormInstanceID],
[demForm].[FormInstance_AnswerTypeID]))
|--Nested Loops(Inner Join,
WHERE
[demInterviewForm].[SchedID]=[schEntry].[SchedID]))
| |--Nested Loops(Inner Join, OUTER
REFERENCES
[demInterviewForm].[ProbandId]) WITH PREFETCH)
| | |--Nested Loops(Inner Join, OUTER
REFERENCES
[demInterviewForm].[PId]) WITH PREFETCH)
| | | |--Nested Loops(Inner Join, OUTER
REFERENCES
[demInterviewForm].[TargetPId]) WITH PREFETCH)
| | | | |--Nested Loops(Inner Join, OUTER
REFERENCES
[demInterviewForm].[ProcID]))
| | | | | |--Nested Loops(Inner Join, OUTER
REFERENCES
[demInterviewForm].[ProtId]))
| | | | | | |--Nested Loops(Inner Join, OUTER
REFERENCES
[demInterviewForm].[StudyID]))
| | | | | | | |--Nested Loops(Inner Join, OUTER
REFERENCES
[demInterviewForm].[SiteId]))
| | | | | | | | |--Nested Loops(Inner Join)
| | | | | | | | | |--Clustered Index
Seek(OBJECT
[PPDM].[dbo].[demForm].[PK_demForm]),
SEEK
[demForm].[FormID]=Convert([@1])) ORDERED FORWARD)
| | | | | | | | |
|--Filter(WHERE
[demInterviewForm].[StatusFlag]='N'))
| | | | | | | | | |--Compute
Scalar(DEFINE
[demInterviewForm].[SchedID]='@SiteID='+ltrim(str(Convert([de
mInterviewForm].[SiteId]), NULL,
NULL))+',@ProbandId='+ltrim(str(Convert([demInterviewForm].[ProbandId]),
NULL, NULL))+',@StudyID='+ltrim(str(Convert([demInterviewForm].[StudyID]),
NULL, NULL))+',@PId='+ltrim(str(Convert([demInterviewForm].[PId]), NULL,
NULL))+',@ProtId='+ltrim(str(Convert([demInterviewForm].[ProtId]), NULL,
NULL))+',@ProcID='+ltrim(str(Convert([demInterviewForm].[ProcID]), NULL,
NULL))+',@InterviewId='+ltrim(str(Convert(dbo.demInterviewForm.[InterviewId]
), NULL, NULL))))
| | | | | | | | | |--Bookmark
Lookup(BOOKMARK
[Bmk1000]), OBJECT
[PPDM].[dbo].[demInterviewForm]))
| | | | | | | | | |--Index
Seek(OBJECT
[PPDM].[dbo].[demInterviewForm].[XIFdemInterviewForm_FormID_For
mInstanceID]), SEEK
[demInterviewForm].[FormID]=Convert([@1])) ORDERED
FORWARD)
| | | | | | | | |--Clustered Index
Seek(OBJECT
[PPDM].[dbo].[admSite].[PK__admSite__526FE1FF]),
SEEK
[admSite].[SiteId]=[demInterviewForm].[SiteId]) ORDERED FORWARD)
| | | | | | | |--Clustered Index
Seek(OBJECT
[PPDM].[dbo].[admStudy].[PK__admStudy__53640638]),
SEEK
[admStudy].[StudyID]=[demInterviewForm].[StudyID]) ORDERED FORWARD)
| | | | | | |--Clustered Index
Seek(OBJECT
[PPDM].[dbo].[admProtocol].[PK__admProtocol__517BBDC6]),
SEEK
[admProtocol].[ProtId]=[demInterviewForm].[ProtId]) ORDERED FORWARD)
| | | | | |--Clustered Index
Seek(OBJECT
[PPDM].[dbo].[admProcedure].[PK__admProcedure__5087998D]),
SEEK
[admProcedure].[ProcID]=[demInterviewForm].[ProcID]) ORDERED FORWARD)
| | | | |--Clustered Index
Seek(OBJECT
[PPDM].[dbo].[pimParticipant].[PK_pimParticipant]),
SEEK
[pimParticipant].[PId]=[demInterviewForm].[TargetPId]) ORDERED
FORWARD)
| | | |--Clustered Index
Seek(OBJECT
[PPDM].[dbo].[pimParticipant].[PK_pimParticipant]),
SEEK
[pimParticipant].[PId]=[demInterviewForm].[PId]) ORDERED FORWARD)
| | |--Clustered Index
Seek(OBJECT
[PPDM].[dbo].[pimParticipant].[PK_pimParticipant]),
SEEK
[pimParticipant].[PId]=[demInterviewForm].[ProbandId]) ORDERED
FORWARD)
| |--Compute
Scalar(DEFINE
[schEntry].[SchedID]='@SiteID='+ltrim(str(Convert(dbo.schEntr
y.[SiteID]), NULL,
NULL))+',@ProbandId='+ltrim(str(Convert(dbo.schEntry.[ProbandId]), NULL,
NULL))+',@StudyID='+ltrim(str(Convert(dbo.schEntry.[StudyID]), NULL,
NULL))+',@PId='+ltrim(str(Convert(dbo.schEntry.[PId]), NULL,
NULL))+',@ProtId='+ltrim(str(Convert(dbo.schEntry.[ProtId]), NULL,
NULL))+',@ProcID='+ltrim(str(Convert(dbo.schEntry.[ProcID]), NULL,
NULL))+',@InterviewId='+ltrim(str(Convert(dbo.schEntry.[InterviewId]), NULL,
NULL))))
| |--Index
Scan(OBJECT
[PPDM].[dbo].[schEntry].[XIFschEntry_PIDStudySiteProc]))
|--Row Count Spool
|--Nested Loops(Inner Join, OUTER
REFERENCES
[demAnswerTypeOptions].[OptionID]))
|--Clustered Index
Seek(OBJECT
[PPDM].[dbo].[demAnswerTypeOptions].[PK_demAnswerTypeOptions]),
SEEK
[demAnswerTypeOptions].[AnswerTypeID]=[demForm].[FormInstance_AnswerTy
peID]) ORDERED FORWARD)
|--Clustered Index
Seek(OBJECT
[PPDM].[dbo].[demOptions].[PK__demOptions__09A971A2]),
SEEK
[demOptions].[OptionId]=[demAnswerTypeOptions].[OptionID]),
WHERE
[demInterviewForm].[FormInstanceID]=[demOptions].[OptionValue])
ORDERED FORWARD)
You can see why I am surprised!
Regards,
Brian