Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics SL (Archived)

What are the implications of adding an index on Project, Gl_acct in PJTran

Posted on by 55

I'm developing a project-oriented report that requires using the gl_acct field in PJTran to do some rate look-ups in the Allocator rate tables to calculate OH amounts.  It is necessary to perform all calculations in SQL and I'm using several views along with a table function to produce the results needed. The Performance is lousy and I believe that creating an additional index (non-unique) based on Project + GL_Acct in PJTran should improve it.  My question is: Are there any "gotchas" that I should be aware of before adding a new index to this table.  I've considered indexed views, but they must be created with schema binding to PJTran, and I don't want to go there.  Anybody have another idea?       

*This post is locked for comments

  • Russell Burleson Profile Picture
    Russell Burleson 55 on at
    Re: What are the implications of adding an index on Project, Gl_acct in PJTran

    Hi Paul,

    I've added the indices to the table and tweaked my code per your recommendations and it has improved my report performance significantly.  Much of the technical advice on SQL Server is rather "thick", making it difficult to parse out what is useful, but you've done an excellent job laying it out in a way that is easy to comprehend.  I will definitely reuse it time and time again.  Thank you for the advice and for taking the time to respond.      

  • Verified answer
    Paul Phillips Profile Picture
    Paul Phillips 590 on at
    Re: What are the implications of adding an index on Project, Gl_acct in PJTran

    Hi Rusty,

    Indexes are generally fine to add. Don't add clustered or unique indexes as they may interfere with SL. Standard tables usually have a clustered index already. Standard SL indexes that are used by the kernel and screens usually end in a number. Custom indexes that you add can be named whatever you like.

    Indexed (materialized) views are not supported in SL. If you add one to a table it will cause a fatal exception in SL when the table is updated. Also, anything that modifies the structure of standard SL tables (number of fields, field types/lengths, computed columns, etc.) is disallowed. The table buffers compiled into the application must match the schema exactly.

    Below are some non SL-specific suggestions applicable to SQL Server indexing/performance from my experience. These might help you or benefit others:

    1. Try to get the columns that you are filtering on in the predicate (WHERE clause) into your index, and also add columns from the SELECT list as 'included' columns if the list isn't too long. This can allow the database to satisfy the query directly from the index itself.

    2. Avoid doing computations on or using user-defined functions on columns in your predicate, as that can prevent the database from using indexes and you can end up with a table scan instead.

    3. Avoid cursors/loops, especially in reports. There very few cases where cursors are appropriate at a reporting level. Usually cursors on a report will destroy performance.

    4. Avoid temp tables - these will hit the tempdb and cause a lot of disk I/O.

    5. Make sure that you have a maintenance plan to rebuild the indexes periodically so that they don't get too fragmented.

    6. Avoid nesting too many sql objects in your query, such as views. In my experience it's best not to have more than 2 levels deep from you query to the underlying table.

    7. Try to narrow your report selection criteria as far as possible with parameters, for example, using PerPost on transaction tables at a minimum.

    Hope this helps.

    Paul Phillips

    Principal Development Consultant

    www.Abalu.net

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans