如何在activepivot的数据存储区中加速一系列类似的查询?

时间:2014-09-04 09:32:33

标签: performance prepared-statement activepivot

在我的activepivot解决方案中,我有一个商店,其中包含每个交易的桌面和货币。

例如:

  • 1,eur,DeskA,10
  • 2,eur,DeskB,18
  • 3,gbp,DeskA,17
  • 4,usd,DeskA,54

我有很多疑问,我想查找所有记录 包含deskA和特定但不断变化的货币。

执行这三个查询:

  • DeskA,eur
  • DeskA,usd
  • DeskA,gbp

我会使用预准备语句来避免多次解析查询。 在activepivot中有没有等效的东西?

1 个答案:

答案 0 :(得分:0)

这是您定义预编译查询的方法

IRecordQuery query = new RecordQuery("storeName", Equal("attributeUsedForSearchHere").parametrized(0), Arrays.asList("attribute2", "attribute3", "attribute4"));
compiledQuery = datastore.getQueryManager().compile(query);

这是你可以执行它的方式

ICursor cursor = datastore.getQueryManager().execute(compiledQuery , new Object[] { valueOfAttributeUsedForSearchHere} );

基本上,你使用attributeUsedForSearchHere作为你基于相同条件用于搜索的属性;当然,你可能有几个属性。

然后一旦执行查询,您就可以读取其他属性(attribute2,3和4),如下所示:

cursor.getRecord().read("attribute2")