-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve efficiency of DirectLink / Tree work item queries #30
Labels
Milestone
Comments
TL;DR _642 work items queried and mapped in under 30 seconds_ Loading 642 work items queried in two trips to VSO.
Once the Here's the WIQL output with timings
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Setup
Given a work item structure
Problem
The existing implementation:
Would need to perform the following:
WorkItems
where WIT = Deliverable and Id = 1SELECT * FROM WorkItems WHERE [System.WorkItemType] = 'Deliverable' AND [System.Id] = 1
Deliverable
and fieldsWorkItemLinks
to get theTask
childrenSELECT * FROM WorkItemsLinks WHERE Source.[System.WorkItemType] = 'Deliverable' AND Source.[System.Id] = 1 AND [System.Links.LinkType] = 'System.LinkTypes.Hierarchy-Forward' AND Target.[System.WorkItemType] = 'Task'
WorkItems
where Id=2SELECT * FROM WorkItems WHERE [System.Id] IN (2)
Task
and fieldsWorkItems
where WIT = Deliverable and Id = 1 (repeat of 1)SELECT * FROM WorkItems WHERE [System.WorkItemType] = 'Deliverable' AND [System.Id] = 1
Deliverable
and fields (repeat of 2)WorkItemLinks
to get theBug
childrenSELECT * FROM WorkItemsLinks WHERE Source.[System.WorkItemType] = 'Deliverable' AND Source.[System.Id] = 1 AND [System.Links.LinkType] = 'System.LinkTypes.Hierarchy-Forward' AND Target.[System.WorkItemType] = 'Bug'
WorkItems
where Id=3SELECT * FROM WorkItems WHERE [System.Id] IN (3)
Bug
and fieldsThe operation requires six trips to VSO in order to hydrate the items.
Proposal
When performing a DirectLink (e.g. Parent / Child, Child / Parent), or a Tree (Parent / Child / Grandchild), use
IWorkItemStore.QueryLinks
method to first query for all link relationships, **SELECT * FROM WorkItemsLinks WHERE Source.[System.WorkItemType] = 'Deliverable' AND Source.[System.Id] = 1 AND [System.Links.LinkType] = 'System.LinkTypes.Hierarchy-Forward' AND (Target.[System.WorkItemType] = 'Task' OR Target.[System.WorkItemType] = 'Bug')
SELECT * FROM WorkItems WHERE [System.Id] IN (1, 2, 3)
The call to
IWorkItemStore.QueryLinks
returnsIEnumerable<IWorkItemLinkInfo>
, which would house the following results given our scenario.The results represent the tree having one level of children (additional levels set the SourceId and TargetId accordingly). The fields are then mapped using a 'flat' TFS query of regular IDs, which is inherently fast.
Note: this works for DirectLink and Tree when no ASOF is requested. When ASOF is requested, only Flat and DirectLink queries are supported.
http://blogs.msdn.com/b/jsocha/archive/2012/02/22/retrieving-tfs-results-from-a-tree-query.aspx
The text was updated successfully, but these errors were encountered: