tags:

views:

27

answers:

1

hi,

i've got a sql-query, executed against non-ax-tables ( partially at least ) from x++ via odbc. the sql-query-execution-plan suggests to add an index to the referring ax-table, eg:

CREATE NONCLUSTERED INDEX [] ON [ ([field1]) INCLUDE ([several fields])

i remember it wasn't a good idea to create any of those indices via management-studio on the ax-tables, but how to create such an index via ax? should the fields in the include block simply be added in the field-list?

another index-hint was an easier one:

CREATE NONCLUSTERED INDEX [] ON [] ([field1],[field2])

but even creating this index in ax on the regarding table and the named field - the query analyzer still suggests to create this index.

viewing the create-statement for this index in sql managmement-studio, the dataAreaID-column is included ( automatically )....

any hints? thanks in advance!


answer to comments:

it is a sql-query executed from x++. the tables used are partially ax-tables and partially not. the only index which seems missing is one on the ax-table.

i didn't want to discuss index optimizations in general, but just ask if there's a possibility to add an index in ax, representing the "include..." part of the first "create-index-query"!

i surely know about the fact to regard the DAID-column in queries outside ax - i was just surprised that the management-studio criticizes a missing index for fieldA + fieldB, when in fact this index is already existing ( regarding the DAID automatically ).

thanks 4 reply!

A: 

The fact that it suggest fieldA+fieldB indicates, that you do not have a DataAreaId selection on a query.

AX always adds DataAreaId as the first field in an index.

Also you can analyze you SQL query, to get an execution plan by putting the SQL in the Execution plan dialog in Administration/Inquiries/Database statements ...

This will indicate what indices are in use.

Jan B. Kjeldsen