1

我正在使用这个查询:

select * 
from   MailMessagesReceived mmd
inner  
join   MailMessageAttachments mmt
on     mmd.ID = mmt.ID
Where  mmd.created > '2017-01-01'
And    mmd.SenderMailbox = 'finappanl@lyanthe.com'
And    mmd.RecipientStatusDescription = 'Prepared'

我得到一个没有消息代码的超时错误。上面写着“Er is een time-out opgetreden voor de bewerking”。以下详细信息附加到错误中:

select * from MailMessagesReceived
inner join MailMessageAttachments
on MailMessagesReceived.ID = MailMessageAttachments.ID
Where MailMessagesReceived.created > "2017-01-01"
And MailMessagesReceived.SenderMailbox = "finappanl@lyanthe.com"
And MailMessagesReceived.RecipientStatusDescription = "Prepared"

Type: System.Net.WebException
bij System.Net.HttpWebRequest.GetResponse()
bij Invantive.Data.ODataProvider.DoRequest(HttpWebRequest request, String url, String partition, String& returnUrl, Dictionary`2& headers) in File161:regel 3666
bij Invantive.Data.ODataProvider.GetInternal(String relativeUrl, String mimeType, String partition, Boolean allowFromCache, String& returnUrl, Dictionary`2& headers, Boolean& fromCache) in File161:regel 3001
bij Invantive.Data.ODataProvider.Get[T](String relativeUrl, Dictionary`2& headers, String& fullUrl, Boolean& resultFromCache, String partition, Boolean allowFromCache, String mimeType) in File161:regel 2880
bij Invantive.Data.ODataProvider.ReadDataFromServiceResponse(List`1 rows, String basePath, List`1 allFieldTypes, String url, String partition, ObjectDefinition objectDefinition, QueryObject queryObject, Int32& pagesRetrieved, Int32& rowsRetrieved) in File161:regel 1102
bij Invantive.Data.ODataProvider.FetchDataOnePartition(String serviceUrl, String partition, List`1 rows, String basePath, List`1 allFieldTypes, ObjectDefinition objectDefinition, QueryObject queryObject, ParameterList parameters) in File161:regel 1021
bij Invantive.Data.ODataProvider.<>c__DisplayClass72_3.<Fetch>b__2(String partition) in File161:regel 877
--- Einde van stacktracering vanaf vorige locatie waar uitzondering is opgetreden ---
bij Invantive.Data.ODataProvider.Fetch(EntityFieldCollection entityFields, QueryObject queryObject, ParameterList parameters, Boolean fetchSingle, Boolean fetchCountFirst, Int32 pagingSteps, Boolean fetchCount, ResultSet& resultSet, Int32& totalNumberOfRows) in File161:regel 914
bij Invantive.Data.ExactOnlineProvider.Fetch(EntityFieldCollection entityFields, QueryObject queryObject, ParameterList parameters, Boolean fetchSingle, Boolean fetchCountFirst, Int32 pagingSteps, Boolean fetchCount, ResultSet& resultSet, Int32& totalNumberOfRows) in File298:regel 909
bij Invantive.Data.ConnectionManager.ExecuteProviderFetch(EntityFieldCollection entityFields, QueryObject queryObject, ParameterList parameters, Boolean fetchSingle, Boolean fetchCountFirst, Int32 pagingSteps, Boolean fetchCount, Int32& totalNumberOfRows, String& handlingPath) in File39:regel 3190
bij Invantive.Data.ConnectionManager.Fetch(EntityFieldCollection entityFields, QueryObject queryObject, ParameterList parameters, Boolean fetchSingle, Boolean fetchCountFirst, Int32 pagingSteps, Boolean fetchCount) in File39:regel 1406
bij Invantive.Sql.DataSourceOrFunctionTree.<GetDataFromDataContainer>d__29.MoveNext() in File120:regel 315
bij System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
bij System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
bij Invantive.Sql.FirehoseResultSet.<Iterator>d__54.MoveNext() in File133:regel 547
bij System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
bij System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
bij Invantive.Sql.FirehoseResultSet.<Iterator>d__54.MoveNext() in File133:regel 559
bij System.Linq.Buffer`1..ctor(IEnumerable`1 source)
bij System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
bij Invantive.Sql.JoinIterator.<JoinInternal>d__13.MoveNext() in File135:regel 481
bij Invantive.Sql.FilterIterator.<Iterator>d__3.MoveNext() in File132:regel 92
bij Invantive.Sql.ChainedFirehose.<Iterator>d__11.MoveNext() in File130:regel 81
bij Invantive.Sql.SelectListIterator.<Iterator>d__7.MoveNext() in File138:regel 119
bij System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
bij System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
bij Invantive.Sql.QueryPlan.Fetch() in File140:regel 91
bij Invantive.Data.ConnectionManager.ExecuteProviderPassthroughSqlActionTable(String actionSql, ParameterList parameters, String& handlingPath) in File39:regel 4033
--- Einde van stacktracering vanaf vorige locatie waar uitzondering is opgetreden ---
bij System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
bij Invantive.Data.ConnectionManager.ExecuteProviderPassthroughSqlActionTable(String actionSql, ParameterList parameters, String& handlingPath) in File39:regel 4062
bij Invantive.Data.ConnectionManager.PassthroughSqlActionTable(String actionSql, ParameterList parameters) in File39:regel 2086
--- Einde van stacktracering vanaf vorige locatie waar uitzondering is opgetreden ---
bij System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
bij Invantive.Data.ConnectionManager.PassthroughSqlActionTable(String actionSql, ParameterList parameters) in File39:regel 2098
bij Invantive.Data.ActionProceduresBase.PassthroughSqlActionTable(String actionSql, ParameterList parameters) in File29:regel 134
bij Invantive.Producer.Windows.Forms.QueryTool.ExecuteStatement(IProgressNotifier notifier, String statement, ParameterList bindVariables, Boolean showResultsInGrid, Boolean showStatistics, Boolean memorizeStatisticsInSqlHistory, Boolean allowPaging) in File948:regel 2847
bij Invantive.Producer.Windows.Forms.QueryTool.FetchResultsFromSql() in File948:regel 2430

我正在尝试了解 Exact Online 中的“Scan en Herken”(即扫描和识别发票)收件箱的概览。此收件箱包含发票和计算机生成的帐户条目,每个条目都是:

  • 准备好处理(绿色),
  • 需要一些改动(黄色)
  • 或需要手动处理(红色)。

我们想具体了解这三个不同州的每一个州有多少张发票。对于那些需要更改或手动更正的人,我们想知道错误是什么。

通过我使用的查询,我只是在四处挖掘以找出 MailMessageAttachments 表中包含哪些数据。我不知道我是否在正确的地方挖掘,所以关于这个主题的任何建议都会很好。此外,我想知道为什么我的 SQL 代码会引发超时。

4

1 回答 1

1

有一些可能的改进。Exact Online 的 REST API 邮件消息 (JSON) 最近进行了重组以提高性能,但仍然不是最快的。

请首先确保您只选择您想要使用的部门,例如使用:

use 123456,345678,56789

而不是使用:

use all

从带有一些样本数据的小部门开始,当查询工作时,通过在更大的部门上进行测试来提高性能。

此外,您可能希望确保不会发生隐式数据类型转换,因此更喜欢:

date-field > to_date('20170101', 'yyyymmdd')

date-field > '2017-01-01'

在这个查询中,它可能不会受到伤害。

最好查询状态码而不是描述。描述因国家而异,甚至因用户而异。代码可能已被索引,而可翻译的描述则没有。

此外,并非所有邮件都会有附件,因此最好使用左外连接。

此外,MailMessageAttachments 表可以是一个巨大的表(许多文档以二进制格式包含,尤其是当人们使用灰度或彩色扫描仪时)。每行可以下载数兆字节,因此最好仅在绝对需要时才加入。

最后,您可以在使用 'top' 或 'limit' 语法检索到有限数量的行后停止运行查询。

结果查询:

select * 
from   MailMessagesReceived mmd
left 
outer
join   MailMessageAttachments mmt
on     mmd.ID = mmt.ID
Where  mmd.created > to_date('20170101', 'yyyymmdd')
And    mmd.SenderMailbox = 'Facturen@ExactOnline.nl' --     'finappanl@lyanthe.com'
and    mmd.recipientstatus = 20 /* Open. Etc, look up for Prepared. Enables index use. */
limit 50

使用 运行 30 个小分区set requests-parallel-max 8时,该行大约需要 1 分钟。

PS。请注意,您可以使用select * from exactonlinerest..sessionios.

于 2017-01-25T15:42:06.260 回答