Thursday, March 29, 2012

Error loading Query Execution Plan

I am trying to tune a very long running query (18 minutes on an Axim X51, 8secs on my laptop), but I can't get the query plan file that is generated on the device to load in the Sql Server Management Studio. I am using the Sql Everywhere CTP on the device, and version 9.00.2047 of the management studio shell.

FWIW, when I try to create the execution plan by running the same query on a .sdf file local on my laptop, I get a similar error trying to view the query plan.

Apart from the query plan issues, it would appear (just from the query execution time) that the indexes defined on the sdf file are not being used when executing the query on the device, but are being used when executing the query on the laptop. This is pure SWAG on my part, though.

I can't figure out how to attach a file to the post, unfortunately.

Thanks for any help you can offer.

Matthew Belk, BizSpeed, Inc.

Matthew,

What is the error that you get when loading the query execution plan in Management Studio? My guess is that it would be an issue in rendering the graphical execution plan. However, you can still see the plan information from the plan file (xml format).

Also, the query plan usually does not differ on the laptop and the device.

|||

I was able to identify the query bottleneck by manually interpreting the plan file, but it was an arduous task sifting through all that XML. There was a similar issue posted to the Feedback section in the SQL Server area of the Microsoft Connect website (issue id 231137) that I validated and commented on. That issue was marked closed/fixed, but there were no additional comments.

Thanks, Matthew

Here is the text of the plan file:

===================================

Error loading execution plan XML file C:\Documents and Settings\mbelk\My Documents\batitem.sqlplan. (SQLEditors)


Program Location:

at Microsoft.SqlServer.Management.UI.VSIntegration.Editors.ShowPlan.ShowPlanControl.LoadXml(String xmlFile)
at Microsoft.SqlServer.Management.UI.VSIntegration.Editors.ShowPlan.Editor.Microsoft.VisualStudio.Shell.Interop.IPersistFileFormat.Load(String fileName, UInt32 grfMode, Int32 readOnly)

===================================

Exception has been thrown by the target of an invocation. (mscorlib)


Program Location:

at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.SqlServer.Management.SqlMgmt.ShowPlan.ObjectWrapperTypeConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
at System.ComponentModel.TypeConverter.ConvertFrom(Object value)
at Microsoft.SqlServer.Management.SqlMgmt.ShowPlan.ObjectWrapperTypeConverter.ConvertToObjectWrapper(Object item)
at Microsoft.SqlServer.Management.SqlMgmt.ShowPlan.ObjectWrapperTypeConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
at System.ComponentModel.TypeConverter.ConvertFrom(Object value)
at Microsoft.SqlServer.Management.SqlMgmt.ShowPlan.PropertyFactory.CreateProperty(PropertyDescriptor property, Object value)
at Microsoft.SqlServer.Management.SqlMgmt.ShowPlan.ObjectParser.ParseProperties(Object parsedItem, PropertyDescriptorCollection targetPropertyBag, NodeBuilderContext context)
at Microsoft.SqlServer.Management.SqlMgmt.ShowPlan.XmlPlanParser.Parse(Object item, Object parentItem, Node parentNode, NodeBuilderContext context)
at Microsoft.SqlServer.Management.SqlMgmt.ShowPlan.XmlPlanParser.Parse(Object item, Object parentItem, Node parentNode, NodeBuilderContext context)
at Microsoft.SqlServer.Management.SqlMgmt.ShowPlan.XmlPlanParser.Parse(Object item, Object parentItem, Node parentNode, NodeBuilderContext context)
at Microsoft.SqlServer.Management.SqlMgmt.ShowPlan.XmlPlanParser.Parse(Object item, Object parentItem, Node parentNode, NodeBuilderContext context)
at Microsoft.SqlServer.Management.SqlMgmt.ShowPlan.XmlPlanParser.Parse(Object item, Object parentItem, Node parentNode, NodeBuilderContext context)
at Microsoft.SqlServer.Management.SqlMgmt.ShowPlan.XmlPlanParser.Parse(Object item, Object parentItem, Node parentNode, NodeBuilderContext context)
at Microsoft.SqlServer.Management.SqlMgmt.ShowPlan.XmlPlanParser.Parse(Object item, Object parentItem, Node parentNode, NodeBuilderContext context)
at Microsoft.SqlServer.Management.SqlMgmt.ShowPlan.XmlPlanParser.Parse(Object item, Object parentItem, Node parentNode, NodeBuilderContext context)
at Microsoft.SqlServer.Management.SqlMgmt.ShowPlan.XmlPlanParser.Parse(Object item, Object parentItem, Node parentNode, NodeBuilderContext context)
at Microsoft.SqlServer.Management.SqlMgmt.ShowPlan.XmlPlanParser.Parse(Object item, Object parentItem, Node parentNode, NodeBuilderContext context)
at Microsoft.SqlServer.Management.SqlMgmt.ShowPlan.XmlPlanParser.Parse(Object item, Object parentItem, Node parentNode, NodeBuilderContext context)
at Microsoft.SqlServer.Management.SqlMgmt.ShowPlan.XmlPlanParser.Parse(Object item, Object parentItem, Node parentNode, NodeBuilderContext context)
at Microsoft.SqlServer.Management.SqlMgmt.ShowPlan.XmlPlanParser.Parse(Object item, Object parentItem, Node parentNode, NodeBuilderContext context)
at Microsoft.SqlServer.Management.SqlMgmt.ShowPlan.XmlPlanParser.Parse(Object item, Object parentItem, Node parentNode, NodeBuilderContext context)
at Microsoft.SqlServer.Management.SqlMgmt.ShowPlan.XmlPlanNodeBuilder.Execute(Object dataSource)
at Microsoft.SqlServer.Management.UI.VSIntegration.Editors.ShowPlan.ShowPlanControl.LoadXml(String xmlFile)

===================================

Exception has been thrown by the target of an invocation. (mscorlib)


Program Location:

at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.SqlServer.Management.SqlMgmt.ShowPlan.ObjectWrapperTypeConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
at System.ComponentModel.TypeConverter.ConvertFrom(Object value)
at Microsoft.SqlServer.Management.SqlMgmt.ShowPlan.PropertyFactory.CreateProperty(PropertyDescriptor property, Object value)
at Microsoft.SqlServer.Management.SqlMgmt.ShowPlan.ObjectParser.ParseProperties(Object parsedItem, PropertyDescriptorCollection targetPropertyBag, NodeBuilderContext context)
at Microsoft.SqlServer.Management.SqlMgmt.ShowPlan.ExpandableObjectWrapper..ctor(Object item, String defaultPropertyName, String displayName)
at Microsoft.SqlServer.Management.SqlMgmt.ShowPlan.ObjectWrapperTypeConverter.Convert(SeekPredicateType item)

===================================

Object reference not set to an instance of an object. (SqlMgmt)


Program Location:

at Microsoft.SqlServer.Management.SqlMgmt.ShowPlan.ExpandableArrayWrapper.PopulateProperties(ICollection collection)
at Microsoft.SqlServer.Management.SqlMgmt.ShowPlan.ObjectWrapperTypeConverter.ConvertToObjectWrapper(Object item)
at Microsoft.SqlServer.Management.SqlMgmt.ShowPlan.ObjectWrapperTypeConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
at System.ComponentModel.TypeConverter.ConvertFrom(Object value)
at Microsoft.SqlServer.Management.SqlMgmt.ShowPlan.PropertyFactory.CreateProperty(PropertyDescriptor property, Object value)
at Microsoft.SqlServer.Management.SqlMgmt.ShowPlan.ObjectParser.ParseProperties(Object parsedItem, PropertyDescriptorCollection targetPropertyBag, NodeBuilderContext context)
at Microsoft.SqlServer.Management.SqlMgmt.ShowPlan.ExpandableObjectWrapper..ctor(Object item, String defaultPropertyName, String displayName)
at Microsoft.SqlServer.Management.SqlMgmt.ShowPlan.ObjectWrapperTypeConverter.Convert(ScanRangeType item)

|||

Sorry about that. I checked out the details.

This error shows up whenever more than one column of a composite index is being used for a seek or scan.

e.g.

select * from
stores, sales where
sales.stor_id = stores.stor_id
and sales.ord_num = 'test'
- with a composite index on sales.stor_id and sales.ord_num.

For a work around, choose only one column from the index while tuning the query initially.

e.g.

select * from
stores, sales where
sales.stor_id = stores.stor_id

The plan that you get should be similar to the actual plan. For the final pass of tuning the query, use the full query!

Thanks

Pragya

sql

No comments:

Post a Comment