向 axapta 表添加索引

发布于 2024-09-08 07:36:55 字数 766 浏览 4 评论 0原文

我有一个sql查询,通过odbc从x++针对非ax表(至少部分)执行。 sql-query-execution-plan 建议向引用的 ax-table 添加索引,例如:

CREATE NONCLUSTERED INDEX [] 开 [ ([字段 1]) INCLUDE ([several fields])

我记得通过 management-studio 在 ax-tables 上创建任何这些索引都不是一个好主意,但是如何通过 ax 创建这样的索引?包含块中的字段是否应该简单地添加到字段列表中?

另一个索引提示更简单:

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

但即使在相关表和命名字段上的 axe 中创建此索引 - 查询分析器仍然建议创建此索引。

在 sql managmement-studio 中查看此索引的创建语句,包含 dataAreaID 列(自动)....

有任何提示吗? 提前致谢!


回答评论:

它是从 x++ 执行的 sql 查询。使用的表格部分是斧头表,部分不是。 唯一似乎缺失的索引是斧头表上的索引。

我不想一般性地讨论索引优化,只是想问是否有可能在 ax 中添加索引,代表第一个“创建索引查询”的“包含...”部分!

我当然知道在 ax 之外的查询中考虑 DAID 列的事实 - 我只是惊讶于管理工作室批评 fieldA + fieldB 缺少索引,而事实上该索引已经存在(自动关于 DAID)。

谢谢4位回复!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

脸赞 2024-09-15 07:36:55

事实上,它建议 fieldA+fieldB 表明您在查询中没有 DataAreaId 选择。

AX 始终将 DataAreaId 添加为索引中的第一个字段。

您还可以分析 SQL 查询,通过将 SQL 放入管理/查询/数据库语句的执行计划对话框中来获取执行计划...

这将指示正在使用哪些索引。

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.

时间海 2024-09-15 07:36:55

我也有类似的担忧,这里有一篇文章介绍了如何在 AX 表上创建包含包含的索引。

本质上,您从 X++ 代码创建 SQL 索引:

public static server void createSQLIndexPointTransferHeader()

Connection connection = new Connection();
Statemetn statement = connection.createStatement();
SqlStatementExecutionPermission sqlStatementExecutionPermission;
str createIndexSQL;
;
//Create the index
createIndexSQL = @"IF EXISTS (SELECT * FROM sys.Indexes WHERE onject_id=(N'[dbo].[LIO_POINTTRANSHEADER]) AND name=N'I_NEWWINECLUBCARD_IDX')

DROP INDEX [I_NEWWINECLUBCARD_IDX] ON [dbo].[LIO_POINTTRANSHEADER] WITH (ONLINE=OFF)
CREATE NONCLUSTEREDINDEX INDEX [I_NEWWINECLUBCARD_IDX] ON [dbo].[LIO_POINTTRANSHEADER]
(
[WINECLUBCARDID]
)
INCLUDE ([FIELD1],[FIELD2]/*OTHER FIELDS*/) WITH (PAD_INDEX=OFF /* OTHER WITH OPTIONS*/);

sqlStatementExecutionPermission = new SqlStatementPermission(createIndexSQL);
sqlStatementExecutionPermission .assert;

//BP Deviation Documented
statement.executeUpdate(createIndexSQL);
CodeAccessPermission::revertAssert();

...要根据您的具体要求更新的实际索引文本。

http://daxdilip.blogspot.com /2011/05/tip-how-to-avoid-overriding-of-sql.html

I have had a similirar concern, and here is an article that shows how to create Indexes with Includes on AX tables.

Essentially you create the SQL index from X++ code:

public static server void createSQLIndexPointTransferHeader()

Connection connection = new Connection();
Statemetn statement = connection.createStatement();
SqlStatementExecutionPermission sqlStatementExecutionPermission;
str createIndexSQL;
;
//Create the index
createIndexSQL = @"IF EXISTS (SELECT * FROM sys.Indexes WHERE onject_id=(N'[dbo].[LIO_POINTTRANSHEADER]) AND name=N'I_NEWWINECLUBCARD_IDX')

DROP INDEX [I_NEWWINECLUBCARD_IDX] ON [dbo].[LIO_POINTTRANSHEADER] WITH (ONLINE=OFF)
CREATE NONCLUSTEREDINDEX INDEX [I_NEWWINECLUBCARD_IDX] ON [dbo].[LIO_POINTTRANSHEADER]
(
[WINECLUBCARDID]
)
INCLUDE ([FIELD1],[FIELD2]/*OTHER FIELDS*/) WITH (PAD_INDEX=OFF /* OTHER WITH OPTIONS*/);

sqlStatementExecutionPermission = new SqlStatementPermission(createIndexSQL);
sqlStatementExecutionPermission .assert;

//BP Deviation Documented
statement.executeUpdate(createIndexSQL);
CodeAccessPermission::revertAssert();

... the actual Index text to be updated to your specfic requirements.

http://daxdilip.blogspot.com/2011/05/tip-how-to-avoid-overriding-of-sql.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文