2

I have around 150.000 rows of subscribers answers in a table, and I need to provide a way to let a user select a winner.

I have all this implemented in MS SQL, but because we're having a bit more traffic that expected, I thought it was a good idea to move to a Amazon DynamoDB environment for this particular part (handling subscribers)

in MS SQL I have a SP that is something like:

SELECT s.name, s.guid
FROM calendars c
INNER JOIN challenges cl on cl.calendar_id = c.calendar_id
INNER JOIN challenge_answers ca on ca.calendar_id = c.calendar_id
INNER JOIN subscribers s on s.calendar_id = c.calendar_id
WHERE 
      c.calendar_id = 9 and 
      cl.day = 15 and
      ca.correct = 1 and 
      s.email not like '%@mydomain.com'
ORDER BY s.name DESC;

and using LINQ I end up with .Take(25).Skip(page);

I understand that INNER JOIN's in Amazon DynamoDB are not a viable option, so I added more fields to the subscribers table, witch include all other fields so I can simply have only one table and each item contains everything for the query.

What should be the best approach using Amazon DynamoDB to retrieve only a partial group and safely skip "pages"?

4

2 回答 2

0

DynamoDB 并不是真正设计为跳过页面,而是根据它们的键获取项目。类似查询的功能相当有限,仅适用于具有基本操作的键(散列或范围)。同样,您可以使用已定义索引的键,但同样的限制也适用。这是有关Query的一些附加信息。

关于分页,DynamoDB 不提供游标,因此如果您开始迭代一组键,则需要读取所有项目,直到每个响应中返回的 LastEvaluatedKey 值为 null。目前,没有内置支持跳到特定页面。您可以通过为页面构建索引表来模拟这一点,这样您就可以直接从该索引中获取页面的项目。Chris Moyer在这里提出了一个解决方案。

于 2013-11-17T20:32:16.230 回答
0

您可以尝试使用LINQ2DynamoDB DataContext。它将 DynamoDB 查询结果缓存在内存缓存 (MemcacheD) 中,这极大地提高了 ASP.Net 中排序/分页场景的性能。那里还有一个自定义的ASP.Net DataSource实现,因此您无需一行代码就可以打开分页。

于 2013-12-20T14:29:25.207 回答