如何有效地获取日期范围内的分页查询结果(How to efficiently get paged query results for a date range)
刚开始使用NoSql,特别是DynamodB,我被问到以下问题:
有一个有大量行的现有表,其中的字段如下所示:
RecordId (Guid = partition key) RecordType (Guid = sort key) UserId (Guid) CreationDateTime ... and some other attributes ...
还有一个GSI(比如GSI1):
UserId = partition key RecordType = sort key
某些用户使用相同的RecordType生成大量行(可能每天数百或数千),因此此索引通常具有大量具有相同UserId + RecordType的行。
我希望能够有效地执行分页查询以查找与特定UserId + RecordType匹配的结果,并在一定范围的日期内具有CreationDateTime。
达到此目的的最佳方式是什么?
有人建议我可以用partitionKey = Userid和Sort key = CreationDateTime创建第二个GSI(比如GSI2)。 这个想法是,这将是找到所需日期范围内UserId + RecordType的第一行的有效方法,然后这将用作在GSI1中搜索的起点(PaginationToken)。 只有在GSI1中具有重复键的行按创建顺序存储时才能使用。
这有意义吗? 如果不是,那么更好的方法是什么?
Just starting out with NoSql in general and DynamodB in particular, and I've been asked the following question:
There is an existing table with a large number of rows with fields something like:
RecordId (Guid = partition key) RecordType (Guid = sort key) UserId (Guid) CreationDateTime ... and some other attributes ...
There is also a GSI (say GSI1) with:
UserId = partition key RecordType = sort key
Some users generate a large number of rows with the same RecordType (maybe hundreds or thousands per day), so this index typically has a large number of rows with the same UserId+RecordType.
I want to be able to efficiently execute a paged query for results that match a specific UserId+RecordType, and have a CreationDateTime within a range of dates.
What's the best way to achieve this?
It's been suggested to me that I can create a second GSI (say GSI2) with partitionKey = Userid and Sort key = CreationDateTime. The idea being that this would be an efficient way to find the first row for UserId+RecordType that is in the required date range, and that then this would be used as a starting point (PaginationToken) for searching in GSI1. Which would only work if the rows in GSI1 with a duplicate key are stored in order of creation.
Does this make sense? And if not, what would be a better approach?
原文:https://stackoverflow.com/questions/47657590
满意答案
strcat()需要一个以null结尾的字符串作为输入。 所以strcat(token和&current)将开始读取当前地址并继续运行直到找到null。 只是偶然,你当前在内存中的内容是“\ 001”,所以每次你执行strcat时它都会将所有内容复制到令牌中。
你应该做char current [] =“\ 0 \ 0”,然后用current [0] = chs [++ pos]赋值。 那样,current将始终具有null终止。
strcat() needs a null-terminated string as it's input. so strcat(token, ¤t) will start reading at the address of current and keep going until it finds a null. Just by chance, what you had in memory after current was "\001", so each time you did strcat it copied all that into token.
You should do char current[] = "\0\0" and then assign it with current[0] = chs[++pos]. That way current will always have that null termination.
相关问答
更多scp001真的存在吗,之前有个人和我说了关于001的事,然后我们他和我说这些干嘛,他回复因为
CurrentControlSet与ControlSet001和ControlSet002有什么不同?(How does CurrentControlSet differ from ControlSet001 and ControlSet002?)
Spring Batch - FlatFileItemReader \ 001分隔符问题(Spring Batch - FlatFileItemReader \001 delimiter issue)
如何获得“irb(main):001:0>”提示符而不是“>>”(How do I get the “irb(main):001:0>” prompt instead of “>>”)
试图通过乘以.001来移动小数。(Trying to move the decimal by multiplying by .001. Why is it changing the scale & precision?)
如何将字符串“001”转换为int 001(How to convert a string “001” to int 001)
在Python 3.4.3中使用001时,令牌无效(Invalid token when using 001 in Python 3.4.3)
为什么在调用strcat时添加\ 001(Why \001 is added when strcat is invoked)
Octave strcat忽略添加的空格(Octave strcat ignores added spaces)
使用escape =“false”和值更新h:outputText,其中包含'\ u001c'(Update h:outputText with escape=“false” and value, that contains '\u001c')
相关文章
更多Guava Range类-范围处理
Guava学习笔记:Range
MongoDB学习 (五):查询操作符(Query Operators).1st
[转]So You Want To Be A Producer
常用HQL(Hibernate Query Language)查询
Solr 使用自定义 Query Parser
Solr 使用自定义 Query Parser
Spark - A Fault-Tolerant Abstraction for In-Memory Cluster Computing
Spring Data: a new perspective of data operations
Solr: a custom Search RequestHandler
最新问答
更多获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
如何通过引用返回对象?(How is returning an object by reference possible?)
矩阵如何存储在内存中?(How are matrices stored in memory?)
每个请求的Java新会话?(Java New Session For Each Request?)
css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
xcode语法颜色编码解释?(xcode syntax color coding explained?)
在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!