使用批量插入和查询优化表上的性能(Optimizing Performance on Table with Bulk Inserts and Queries)
我们有一个包含以下模式的表:
CREATE TABLE Measurement ( HubId bigint NOT NULL ,DeviceId bigint NOT NULL ,Timestamp datetime NOT NULL ,Value bigint NOT NULL )
我们希望将记录导入此表中,每秒大约100,000条记录,这些记录将分成多个并发连接。 我可以通过将表视为堆(即没有索引)并使用
SqlBulkCopy
来实现此级别的性能。 每秒都有100,000个唯一的HubId
和DeviceId
组合,Timestamp
递增。Value
是累积的。我们还要求读取最近的两个(在这种情况下为最后一个和倒数第二个 - 插入始终按顺序)值
GROUP BY HubId, DeviceId
每秒一次,但仅用于行的子集(用户是感兴趣的是产生最后两个值之间的实时差异。此外,出于历史目的,我们需要每15分钟将数据汇总到15分钟。 此数据基于前15分钟切片的最大值和当前15分钟切片的最大值进行聚合...这需要在整个数据集中进行,但可以跨多个连接分割,以实现唯一的
HubId
和DeviceId
组合。 因为Value
是累积的,所以这实际上是前一个和当前15分钟切片的最后一个值。使用索引批量插入表会导致升级到独占表锁。 此外,我们似乎无法在不升级到独占表锁的情况下执行查询。
任何人都可以给我一些关于构建这个的最佳方法的指示吗? 我正在撞墙,试图找出最好的方法......
谢谢,迪恩
We have a table with the following schema:
CREATE TABLE Measurement ( HubId bigint NOT NULL ,DeviceId bigint NOT NULL ,Timestamp datetime NOT NULL ,Value bigint NOT NULL )
We'd like to import records into this table at approximately 100,000 records a second which will be split across multiple concurrent connections. I can achieve this level of performance by treating the table as a heap (i.e. no indexes) and using
SqlBulkCopy
. Every second there are 100,000 uniqueHubId
andDeviceId
combinations with theTimestamp
incrementing.Value
is cumulative over time.We also have the requirement to read the two most recent (last and second to last in this case - insert is always in order) values
GROUP BY HubId, DeviceId
once per second but only for a subset of the rows (ones that the user is interested in) to produce a realtime difference between the last two values.In addition we need to aggregate the data once every 15 minutes into 15 minute slices for historical purposes. This data is aggregated based upon the maximum value from the previous 15 minute slice and the maximum from the current 15 minute slice... This needs to occur across the entire dataset but can be split across multiple connections for unique
HubId
andDeviceId
combinations. BecauseValue
is cumulative this is effectively the last value for the previous and current 15 minute slice.Bulk inserting into the table with indexes results in escalation to an exclusive table lock. In addition we can't seem to get the queries to perform without escalating to exclusive table locks.
Can anybody give me some pointers as to the best way of structuring this? I'm banging my head against the wall trying to work out the best way to go...
Thanks, Dean
原文:https://stackoverflow.com/questions/12267619
最满意答案
只是尝试将图像视图的尺寸更改为宽度和高度各25px。 创建多选择器选择器时,我遇到了同样的问题。 我曾在那里使用过上述尺寸。 我不知道问题的确切原因。 我在整个应用程序中使用了像素。
var empty= Ti.UI.createImageView({ image : '/images/boxempty.png', visible : false, right : 10, top : 35, width : 25, height : 25, objName: 'uncheckImage' });
Just try to change the dimension of the image views to 25px each for width and height. I had met with same issue when creating a multiple selector picker. I had used the above dimension there. I don't know the exact reason for issue. I've used pixels in entire application.
var empty= Ti.UI.createImageView({ image : '/images/boxempty.png', visible : false, right : 10, top : 35, width : 25, height : 25, objName: 'uncheckImage' });
相关问答
更多-
我相信你可以通过将包含tableview的窗口的windowSoftInputMode属性设置为Ti.UI.Android.SOFT_INPUT_ADJUST_PAN来摆脱这个问题。 "Window" : { windowSoftInputMode : Ti.UI.Android.SOFT_INPUT_ADJUST_PAN } I believe you can get rid of this issue by setting windowSoftInputMode property of tha ...
-
如何使用Titanium删除Android中的橙色边框onfocus?(How to remove the orange border onfocus in Android using Titanium?)[2023-12-31]
您无法从搜索栏中删除边框。 您可以做的是使用textField创建自定义搜索栏。 为搜索栏创建一个视图,创建一个textField并将其添加到视图中。 然后为texField设置backgroundColor或backgroundImage 。 这是一个例子 var txtSearch = Ti.UI.createTextField({ hintText : 'My hint text', width : '75%', top : '5%', backgroundColo ... -
你在数组中向前迭代,并删除修改数组的行,这样你才能超出界限。 你试过向后迭代吗? tempPickingTable.addEventListener('longclick',function(e){ for (var i=tempPickingTable.data[0].rows.length;i>=0;i--){ if (tempPickingTable.data[0].rows[i].children[0].value === true){ tempPic ...
-
你需要做一个自定义标签,然后row.add(label) 。 https://github.com/appcelerator/titanium_mobile/blob/master/demos/KitchenSink/Resources/examples/table_view_layout_2.js 使用上面的例子,你可以建立你的行看,但你需要他们。 You would need to do a custom label then row.add(label). https://github.com/app ...
-
我有一个非常类似的问题,我可以通过把tableview.setData(tableview.data);修复tableview.setData(tableview.data); 进入任何导致桌子看起来很奇怪的事件。 I had a very similar problem that I was able to fix by putting tableview.setData(tableview.data); into any events that caused the table to look stra ...
-
在Titanium Appcelerator的TableViewRow文档(http://docs.appcelerator.com/titanium/3.0/#!/api/Titanium.UI.TableViewRow-property-selectionStyle)中,您没有属性separatorStyle ,因为它是属性TableView中。 尝试手动make make你的行分隔符(在第一部分): tableViewRow.add( Ti.UI.createView({ ...
-
对于您来说,添加TableView现在的样式属性可能是一个好主意。 你是否使用Ti.UI.SIZE作为TableView的height属性? 如果不是,那么你应该这样做。 如果你这样做,那么在setData方法被调用之后重新设置它可能是一个好主意。 $.my_button.addEventListener('click', function(){ $.my_tableview.setData([]); $.my_tableview.height = Ti.UI.SIZE; }); 现在,另 ...
-
您必须将数据数组分配给表的data属性,以便将这些对象显示为tableView行。 假设: Ti.UI.backgroundColor = 'white'; var win = Ti.UI.createWindow(); var tableData = [ {title: 'Apples'}, {title: 'Bananas'}, {title: 'Carrots'}, {title: 'Potatoes'} ]; var table = Ti.UI.createTableView({ data: ta ...
-
为什么Android中的图像没有显示在TableView上?(Why do Images in Android aren't being shown on a TableView?)[2022-04-23]
我在Android上找到了针对此特定问题的解决方法。 由于需要对图像进行正确渲染的布局刷新,我所做的是为表格制作动画,将其1dp一个方向移动1dp ,并在所述动画的完整性中再次对其进行动画处理,使其返回到原始位置。 这是我使用的代码: var table_bottom = '-1dp' var tableAnimation = Ti.UI.createAnimation({ bottom : table_bottom, duration : 100 }); tableAnimation.a ... -
只是尝试将图像视图的尺寸更改为宽度和高度各25px。 创建多选择器选择器时,我遇到了同样的问题。 我曾在那里使用过上述尺寸。 我不知道问题的确切原因。 我在整个应用程序中使用了像素。 var empty= Ti.UI.createImageView({ image : '/images/boxempty.png', visible : false, right : 10, top : 35, width : 25, height : 25, objNa ...