Axapta 记录列表和临时表

Axapta 记录列表和临时表,axapta,x++,dynamics-365-operations,Axapta,X++,Dynamics 365 Operations,我试图用RecordSortedList解决多个临时表的性能问题,但得到了奇怪的结果。我有一个临时表,其中插入了几十万条记录,然后在其他地方用于连接到其他临时表。问题是在跟踪解析此解决方案之后,插入对于所有单个插入来说花费的时间太长,我希望使用RecordSortedList批量插入到暂存表中。但是,在RecordSortedList.insertDatabase()调用之后,我找不到临时表的句柄 我试过这样的方法: RecordSortedList tmpTableSortedList; My

我试图用RecordSortedList解决多个临时表的性能问题,但得到了奇怪的结果。我有一个临时表,其中插入了几十万条记录,然后在其他地方用于连接到其他临时表。问题是在跟踪解析此解决方案之后,插入对于所有单个插入来说花费的时间太长,我希望使用RecordSortedList批量插入到暂存表中。但是,在RecordSortedList.insertDatabase()调用之后,我找不到临时表的句柄

我试过这样的方法:

RecordSortedList tmpTableSortedList;
MyTempTable myTempTable;
AssetTrans assetTrans;
int i = 1;

tmpTableSortedList = new RecordSortedList(tableNum(MyTempTable));
tmpTableSortedList.sortOrder(fieldNum(MyTempTable, LineNum));

//the real scenario has a much more complicated data gathering, but just for sample
while select * from AssetTrans 
{
    myTempTable.AssetGroup = assetTrans.AssetGroup
    myTempTable.LineNum = i;

    tmpTableSortedList.ins(myTempTable);

    i++;

}

tmpTableSortedList.insertDatabase();

//strange things happen here
MyTempTable myTempTableCopy;
AnotherTmpTable anotherTmpTable;

tmpTableSortedList.first(myTempTableCopy); //returns a buffer, but not usable buffer in join.

//does not work, I imagine because the myTempTableCopy isn't actually pointing to the 
//inserted records above; somehow the temp table is out of scope.
while select * from anotherTmpTable
join myTempTableCopy
where anotherTmpTable.id == myTempTableCopy.id
{
    //logic
}
在调用RecordSortedList.insertDatabase()之后,是否有方法获取指向临时表的指针?我也尝试过linkPhysicalTable()和其他一些东西,但可能RecordSortedList不应该与tempDb表一起使用

编辑:正如Aliaksandr在下面指出的那样,它使用的是
RecordInsertList
,而不是
RecordSortedList

但也许RecordSortedList不应该与tempDb表一起使用

使用
TempDb
表格时出现错误消息:

RecordInsertList或RecordSortedList操作不允许用于数据库临时表。

因此它是不允许的,这可能是有道理的,因为
RecordSortedList
是一个基于内存的对象,而
TempDb
表则不是。我认为您可以,因为我不确定
TempDb
表和
常规
表都存储在磁盘上时是否存在巨大差异

如果要使用
InMemory
表,请查看
\Classes\CustVendSettle
变量
rslTmpOverUnderReverseTax
,该变量使用
InMemory

如果允许使用
表,则可以使用
getPhysicalTableName()
将句柄与
useExistingTempDBTable()
组合使用

还是我误解了你的问题

但也许RecordSortedList不应该与tempDb表一起使用

使用
TempDb
表格时出现错误消息:

RecordInsertList或RecordSortedList操作不允许用于数据库临时表。

因此它是不允许的,这可能是有道理的,因为
RecordSortedList
是一个基于内存的对象,而
TempDb
表则不是。我认为您可以,因为我不确定
TempDb
表和
常规
表都存储在磁盘上时是否存在巨大差异

如果要使用
InMemory
表,请查看
\Classes\CustVendSettle
变量
rslTmpOverUnderReverseTax
,该变量使用
InMemory

如果允许使用
表,则可以使用
getPhysicalTableName()
将句柄与
useExistingTempDBTable()
组合使用

还是我误解了你的问题

我想,这不起作用,因为MyAttendableCopy实际上并没有指向上面插入的记录;不知何故,临时表超出了范围

RecordSortedList
的方法
new
具有额外的
Common
参数,您应该在其中传递tempDB表缓冲区

使用TempDb表时出现错误消息:

不允许对数据库临时表执行RecordInsertList或RecordSortedList操作

这是不允许的,因为RecordSortedList是一个基于内存的对象,而TempDb表则不是

尽管消息说我们不能使用临时表进行此类操作,但事实上我们可以。我们只需要小心,因为代码必须在服务器上执行

我有一个临时表,其中插入了几十万条记录

RecordSortedList对象的大小没有限制,但它们完全基于内存,因此存在潜在的内存消耗问题。因此,在您的情况下,这可能不是最好的解决方案

我想,这不起作用,因为MyAttendableCopy实际上并没有指向上面插入的记录;不知何故,临时表超出了范围

RecordSortedList
的方法
new
具有额外的
Common
参数,您应该在其中传递tempDB表缓冲区

使用TempDb表时出现错误消息:

不允许对数据库临时表执行RecordInsertList或RecordSortedList操作

这是不允许的,因为RecordSortedList是一个基于内存的对象,而TempDb表则不是

尽管消息说我们不能使用临时表进行此类操作,但事实上我们可以。我们只需要小心,因为代码必须在服务器上执行

我有一个临时表,其中插入了几十万条记录


RecordSortedList对象的大小没有限制,但它们完全基于内存,因此存在潜在的内存消耗问题。因此,在您的情况下,这可能不是最好的解决方案。

无法使用InMemory-需要能够在稍后的过程中使用联接,并且只有tempdb允许(或物理)。不管怎样,看起来重新设计都是不可避免的,这是我希望避免的,因为这需要时间。@rjv我不确定你到底在做什么,但你的帖子让人觉得迭代插入是个问题,如果
RecordInsertList
加快了速度,在内存中执行该操作,然后将最后一个表转储到
TempDb
。不过,在这一点上,我认为您的性能问题实际上存在于其他地方。祝你好运!无法使用InMemory-需要能够在进程的后面使用联接,并且只有tempdb允许(或物理)。不管是哪种方式,看起来都像是