/// <summary>
        /// Gets the issues.
        /// </summary>
        /// <param name="xElement">The x element.</param>
        /// <returns>IEnumerable&lt;IPlanIssueResult&gt;.</returns>
        protected override IEnumerable <IPlanIssueResult> GetIssues(XElement xElement)
        {
            if (!(Comparer.Equals(this.RelOpArgs.PhysicalOp, "clustered index scan") || Comparer.Equals(this.RelOpArgs.PhysicalOp, "index scan")))
            {
                yield break;
            }
            if (!(this.RelOpArgs.EstimateRows >= this.CheckParameters.HighScanCount))
            {
                yield break;
            }


            var dbobj     = xElement.GetElement(el.IndexScan, el.Object);
            var dbobjName = dbobj.AttributeString(att.Index, null);
            var pi        = new PlanIssueResult(this.StatementArgs.StatementId)
            {
                Result   = PlanResult.IndexScan,
                Category = PlanCategory.Error,
                NodeId   = this.RelOpArgs.NodeId,
                RowCount = Convert.ToInt64(this.RelOpArgs.EstimateRows)
            };

            if (Comparer.Equals(this.RelOpArgs.PhysicalOp, "clustered index scan"))
            {
                pi.Result = PlanResult.ClusteredIndexScan;
            }

            if (!string.IsNullOrWhiteSpace(dbobjName))
            {
                pi.ObjectName = dbobjName.Replace("[", "").Replace("]", "");
            }
            yield return(pi);
        }
        /// <summary>
        /// Gets the issues.
        /// </summary>
        /// <param name="xElement">The x element.</param>
        /// <returns>IEnumerable&lt;IPlanIssueResult&gt;.</returns>
        protected override IEnumerable <IPlanIssueResult> GetIssues(XElement xElement)
        {
            var element = xElement.GetElement(el.IndexScan);

            if (element == null)
            {
                yield break;
            }
            var lookup = element.AttributeString(att.Lookup, "");

            if (!(Comparer.Equals(lookup, "true") || lookup == "1"))
            {
                yield break;
            }

            var keyLookup = new PlanIssueResult(this.StatementArgs.StatementId)
            {
                Result = PlanResult.KeyLookup, NodeId = this.RelOpArgs.NodeId, Category = PlanCategory.Warning
            };

            if (!this.RelOpArgs.PhysicalOp.ToLower().Contains("index seek"))
            {
                keyLookup.Result = PlanResult.RIDLookup;
            }
            if (this.RelOpArgs.GetOperatorCostPercent(this.StatementArgs.StatementCost) > 5)
            {
                keyLookup.Category = PlanCategory.Error;
            }
            yield return(keyLookup);
        }
示例#3
0
        /// <summary>
        /// Gets the issues.
        /// </summary>
        /// <param name="xElement">The x element.</param>
        /// <returns>IEnumerable&lt;IPlanIssueResult&gt;.</returns>
        protected override IEnumerable <IPlanIssueResult> GetIssues(XElement xElement)
        {
            var joinOps = new[] { "Nested Loops", "Merge Join", "Hash Match" };
            var joins   = xElement.Descendants(el.RelOp).Where(op => joinOps.Contains(op.AttributeString(att.PhysicalOp, ""))).ToList();

            if (joins.Count() <= this.CheckParameters.HighJoinCount)
            {
                yield break;
            }

            var highJoinIssue = new PlanIssueResult(this.StatementArgs.StatementId)
            {
                Result = PlanResult.HighNumberOfJoins, Category = PlanCategory.Warning
            };

            if (joins.Count() > this.CheckParameters.VeryHighJoinCount)
            {
                highJoinIssue.Category = PlanCategory.Error;
            }
            yield return(highJoinIssue);
        }