Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Performance 扫描DynamDB表或查询辅助全局索引或本地索引(最佳解决方案是什么)_Performance_Amazon Dynamodb_Aws Lambda_Query Performance_Nosql - Fatal编程技术网

Performance 扫描DynamDB表或查询辅助全局索引或本地索引(最佳解决方案是什么)

Performance 扫描DynamDB表或查询辅助全局索引或本地索引(最佳解决方案是什么),performance,amazon-dynamodb,aws-lambda,query-performance,nosql,Performance,Amazon Dynamodb,Aws Lambda,Query Performance,Nosql,我有一个名为“Users”的AWS DynamoDB表,它的散列键/主键是由电子邮件组成的“UserID”。它有两个属性,第一个称为“每日点数”,第二个称为“TimePendineApp”。现在我需要在表上运行查询或扫描,这将为我提供得分最高的前50名用户和在应用程序中花费最多时间的前50名用户。现在,cron aws lambda每天只执行一次查询。我正试图找到此查询或扫描的最佳解决方案。对我来说,成本比速度或效率更重要。因为在点上维护辅助全局索引或本地索引可能是代价高昂的操作,因为我必须为这

我有一个名为“Users”的AWS DynamoDB表,它的散列键/主键是由电子邮件组成的“UserID”。它有两个属性,第一个称为“每日点数”,第二个称为“TimePendineApp”。现在我需要在表上运行查询或扫描,这将为我提供得分最高的前50名用户和在应用程序中花费最多时间的前50名用户。现在,cron aws lambda每天只执行一次查询。我正试图找到此查询或扫描的最佳解决方案。对我来说,成本比速度或效率更重要。因为在点上维护辅助全局索引或本地索引可能是代价高昂的操作,因为我必须为这些索引分配读写单元,这是我想要避免的。“用户”表最多有100000到150000条记录,平均有50000条记录。我最好的选择是什么?请建议

我在想,我的第一个选择是,我可以在Filter Expression上扫描整个表,查找某些点以上的记录(例如5000条),在扫描之后,如果找到50条或50条以上的记录,那么只需对这些值进行排序,然后取前50条记录。如果此扫描未返回结果或返回的结果非常少,则减小过滤器表达式值(例如3000),然后再次执行相同的扫描操作。如果筛选器表达式值(例如2500)返回的记录太多,如5000条或更多,则减少筛选器表达式值。这是可能的,我想它还需要处理分页。扫描一张有50000条记录的表格是否可取


任何建议都会有帮助。提前谢谢

首先,为上述用例创建索引并不能简化过程,因为它没有聚合或排序的解决方案

我会将数据导出到配置单元并运行查询,而不是编写代码来确定结果,特别是因为它将是一个每天只执行一次的批处理

如下所示:-

CREATE EXTERNAL TABLE hive_users(userId string, dailyPoints bigint, timeSpendInTheApp bigint) 
STORED BY 'org.apache.hadoop.hive.dynamodb.DynamoDBStorageHandler'
TBLPROPERTIES ("dynamodb.table.name" = "Users",
"dynamodb.column.mapping" = "userId:UserID,dailyPoints:Daily_Points,timeSpendInTheApp:TimeSpendInTheApp");
SELECT dailyPoints, userId from hive_users sort by dailyPoints desc;
SELECT timeSpendInTheApp, userId from hive_users sort by timeSpendInTheApp desc;
创建配置单元表:-

CREATE EXTERNAL TABLE hive_users(userId string, dailyPoints bigint, timeSpendInTheApp bigint) 
STORED BY 'org.apache.hadoop.hive.dynamodb.DynamoDBStorageHandler'
TBLPROPERTIES ("dynamodb.table.name" = "Users",
"dynamodb.column.mapping" = "userId:UserID,dailyPoints:Daily_Points,timeSpendInTheApp:TimeSpendInTheApp");
SELECT dailyPoints, userId from hive_users sort by dailyPoints desc;
SELECT timeSpendInTheApp, userId from hive_users sort by timeSpendInTheApp desc;
查询:-

CREATE EXTERNAL TABLE hive_users(userId string, dailyPoints bigint, timeSpendInTheApp bigint) 
STORED BY 'org.apache.hadoop.hive.dynamodb.DynamoDBStorageHandler'
TBLPROPERTIES ("dynamodb.table.name" = "Users",
"dynamodb.column.mapping" = "userId:UserID,dailyPoints:Daily_Points,timeSpendInTheApp:TimeSpendInTheApp");
SELECT dailyPoints, userId from hive_users sort by dailyPoints desc;
SELECT timeSpendInTheApp, userId from hive_users sort by timeSpendInTheApp desc;