Hey,
I analyzed a job which has a very long runtime. In the client monitor I saw that one SQL-Statement has a runtime around 900ms. This statement uses no index key, so in order to improve it I want to set an index. The sql-statement looks like this: SELECT SUM("Amount") FROM "XXXX" WITH (UPDLOCK, ROWLOCK) WHERE (("Ledger Entry No_"=XXX)) AND (("Entry Type"=X OR "Entry Type"=X)). My question is, if I could create the index in the table in Navision with the following parameters:
Enabled: yes
Key: Ledger Entry No_, Entry Type
SumIndexFields: Amount
Key Groups: <>
MaintainSQLIndex: <Yes>
MaintainSiftIndex: <Yes>
Clustered: <No>
SQL-Index: <Undefined>
Are these settings ok or could there be problem, if I create a new index in a table? I would do this first on a test-system, but I would be more confident, if you have a look at this and give me some advice.
Best regards!
0
Comments
But baseline is don't count to find a silver bullet. You're just plane lucky if you find one.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
How many rows?
http://mibuso.com/blogs/davidmachanick/
Could you post the actual query? Also, what was the time elapsed for this statement?
If the XXXX is a base table (not a VSIFT), you do indeed have a missing SIFT definition, which could speed things up considerably.
Did you filter your Client Monitor output on "Time Elapsed" to see the long running stuff?
Dynamics-NAV.org
As David said, without more details we're all just throwing out guesses.
thanks for all your answers.
@ Davmac: the table is a custom table which has around 700000 voucher entries.
@macuxpc: the query is SELECT SUM("Amount") FROM "XXX$Voucher Entry" WITH (UPDLOCK, ROWLOCK) WHERE (("Voucher Entry No_"=98786)) AND (("Entry Type"=2 OR "Entry Type"=6)) and the elapsed time is 890 ms. Yes I have filtered the output for the long running stuff and this query is the slowest of all.
What other informations do you need? The used SQL-index for this quere is No_. SumIndexField is Amount. Order is Voucher Entry No_, Entry Type, Date, No_. The filter is Voucher Entry No_: 98786, EntryType:resEntry|resEntry (1x per Person). The sql-plan is: Compute Scalar[2,1];Stream Aggregate[3,2];Clustered Index Scan(XXX$Voucher Entry$0)[4,3]
Best regards!
Create the SIFT definition as you had described it in your OP and run the process again. I'm pretty sure it will resolve this long-running query. It should now be a SELECT to a VSIFT instead of the "Voucher Entry".
If you already have an existing index "Voucher Entry No.", "Entry Type", just add "Amount" to the SumIndexFields.
Dynamics-NAV.org
Alternatively - or if the VSIFT does not work - you could try to improve this query by adding a SQL Server site index:
But: adding a new index (directly via SQL or via NAV "Key") eans to increase the "costs" when writing to that table. Thus, you should only do this if you gain a real benefit from this, e.g. if the SELECT SUM query is executed quite often!
NAV/SQL Performance Optimization & Troubleshooting
STRYK System Improvement
The Blog - The Book - The Tool
Those are just a FEW of the first questions I would investigate if tuning a database. Start with this and we can go from there. Though I am sure that other posters will add plenty more questions.
Some text here
workSorry but I have to disagree with this. You have no idea of the selectivity on this table, so adding this sift may actually slow down the query. Worse we don't know the version of NAV or SQL, so you don't know if its SIFT or VSIFT so it could also have a big effect on write performance.
Trust me searching for the Silver Bullet never works.
:thumbsup:
Never said this was a silver bullet ;-) However, it is obviously a bad query and needs to be resolved, either via SIFT or via the SQL-side index with included column Joerg brought up - not only is it a locking SELECT SUM to the base table, it's also a table scan, and it takes almost a full second, every time it is used.
Well, let's wait for feedback from the OP
Dynamics-NAV.org
I tried to change the table, but after I created the new index and tried to compile it I noticed, that I have no rights to change the table. So I have to ask our service provider to compile these changes, but this can sadly take some time. Thanks for all your help and very good feedback!
Best regards!
In the meantime you could try to fix the problem with that index, just to see if that really solves the issue. Once your NAV partner has encoded the Key/VSIFT you should DROP this SQL index.
NAV/SQL Performance Optimization & Troubleshooting
STRYK System Improvement
The Blog - The Book - The Tool
Best regards!