- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在尝试为 mysql 操作与 redis 操作制作基准测试脚本。
这是我尝试过的:
1./ List of comment ids with a separate hash of comment JSON Data mapped to comment id
2./ List of comments json data
3./ Sorted set of comments with ranking and json data as mapped value
由于某种原因,mysql一直不执行redis,我不明白为什么。 我正在查询 100 条记录。
这是我的操作(以尝试分隔):
1./ $client->rpush($commentId); $client->hmset($commentId,$data);
2./ $client->rpush($jsonData);
3./ $client->zadd("comments",$i,$jsonData);
这是我的基准脚本:
$client = new Predis\Client($conf);
$st=microtime(true);
// sorted set solution
$dat=$client->zrange("comments",0,100);
// list solution
//$dat=$client->lrange("comments",0,100);
$ft=microtime(true);
$overall=$ft-$st;
echo "REDIS=>".$overall."\n";
$sta=microtime(true);
$st=mysqli_query($dbh,"select SQL_NO_CACHE * from comments where status>0 order by createdate desc limit 0,100");
while($r=mysqli_fetch_assoc($st)){
$dd=$r;
}
$fta=microtime(true);
$overall=$fta-$sta;
echo "MYSQL=>".$overall."\n";
这是我的排序集的 redis 存储脚本:
$st=mysqli_query($dbh,"select SQL_NO_CACHE * from comments where status>0 order by createdate desc LIMIT 100");
$i=1;
while($r=mysqli_fetch_assoc($st)){
$client->zadd("comments",$i,json_encode($r));
$i++;
}
这是我的列表的 redis 存储脚本:
$st=mysqli_query($dbh,"select SQL_NO_CACHE * from comments where status>0 order by createdate desc LIMIT 100");
$i=1;
while($r=mysqli_fetch_assoc($st)){
$key="comment:$id";
$client->rpush("comments",$key);
foreach($r as $k=>$v){
$client->hset($key,$k,$v);
}
$i++;
}
这是我的没有指向散列的列表的 redis 存储脚本:
$st=mysqli_query($dbh,"select SQL_NO_CACHE * from comments where status>0 order by createdate desc LIMIT 100");
$i=1;
while($r=mysqli_fetch_assoc($st)){
$key="comment:$id";
$client->rpush("comments",json_encode($r));
}
这是数据库架构:
CREATE TABLE `comments` (
`commentid` int(11) NOT NULL AUTO_INCREMENT,
`parentid` int(11) DEFAULT '0',
`refno` int(11) DEFAULT '0',
`createdate` int(11) DEFAULT '0',
`remoteip` varchar(80) DEFAULT '',
`fingerprint` varchar(50) DEFAULT '',
`locid` int(11) DEFAULT '0',
`clubid` int(11) DEFAULT '0',
`profileid` int(11) DEFAULT '0',
`userid` int(11) DEFAULT '0',
`global` int(11) DEFAULT '0',
`official` int(11) DEFAULT '0',
`legacyuser` int(11) DEFAULT '0',
`mediaid` int(11) DEFAULT '0',
`status` int(11) DEFAULT '1',
`comment` varchar(4000) DEFAULT '',
`likes` int(11) DEFAULT '0',
`dislikes` int(11) DEFAULT '0',
`import` int(11) DEFAULT '0',
`author` varchar(50) DEFAULT '',
PRIMARY KEY (`commentid`),
KEY `comments_locid` (`locid`),
KEY `comments_userid` (`userid`),
KEY `idx_legacyusers` (`legacyuser`),
KEY `profile_index` (`profileid`),
KEY `comments_createdate` (`createdate`),
KEY `compound_for_comments` (`locid`,`global`,`status`),
KEY `global` (`global`),
KEY `status` (`status`),
KEY `locid_status` (`locid`,`status`),
KEY `global_status` (`global`,`status`)
) ENGINE=InnoDB
我们使用 Redislabs 作为我们的 redis 服务器。
如果我遗漏了任何使这个问题成为有效问题的信息,请告诉我。
最佳答案
根据以上评论,托管在 AWS 中的远程 Redis 实例的网络延迟大于本地 MySQL 实例的延迟。
自然地,当您为每个 Redis 请求添加 40-100 毫秒的延迟时(取决于您的应用程序与托管的 Redis 在互联网上的距离),它会使 Redis 在总请求时间方面显得更慢。
关于MySQL 优于 Redis,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49655888/
我想显示一个图像(大于 iPhone 的屏幕),用户可以滚动。不难,我已经用这段代码完成了:在我的 .h 文件中 @interface mappa1 : UIViewController { IBO
bash 联机帮助页说: Redirecting Standard Output and Standard Error Bash allows both the standard output (fi
我将大量数据绑定(bind)到 TreeView 控件,因为数据是自然的类别层次结构。问题是它有很多。我已经设法通过仅绑定(bind)那些出现在可见树中的节点来消除大量开销,但这仍然在 ViewSta
我正在尝试为 mysql 操作与 redis 操作制作基准测试脚本。 这是我尝试过的: 1./ List of comment ids with a separate hash of comment
我很想知道是否有比 FileObserver 更好的方法来监视目录的文件更改/创建/删除。 FileObserver 需要持续引用它,这需要持续运行的服务,这很困难,也是一种不好的做法,对吧? 对于如
我创建了一个带有 NSOpenGLView 的窗口,我正在将 openGL 内容渲染到其中。 我想向 View 添加一些按钮和文本字段:我可以使用界面生成器(或代码)添加 NSTextFields 和
如何编码 JAXBElement 列表? 例如,我有一个无法注释的 POJO: public class APojo { private String aString; public APojo()
我正在开发一个博客,我的客户希望在其中使用大量图像(文章、标题、广告等)。他几乎不想要任何文本,因为他希望用阿拉伯语开发博客并且他对网络浏览器支持的任何字体都不满意,他也不想采用 EOT,他将每天更新
我想在文本字段上添加一个标签,该标签会在用户键入时发生变化。问题是文本字段的插入符号位于标签后面(如果我将标签放在文本字段前面)。我始终可以使文本字段的背景透明,并在标签和文本字段后面添加另一个禁用的
我正在尝试在 iOS 应用程序中创建一个特定的布局,其中“背景”是一个 MKMapView,覆盖层是一个 UIScrollView。这个想法是有两个屏幕,一个带有 map ,另一个带有一些附加信息。用
我需要在 UITableViewController 上放置一个 UIView,目前我是这样放置的 [self.navigationController.view addSubview:searchV
我有一个非常简单的问题要问:我需要在屏幕右下角的 ImageView 上放一个小 Logo ,整个屏幕都很大,但我不知道如何设置坐标或如何设置说 ImageViews 处于相对位置。 像这样: 最佳答
我试图让 mapView 覆盖整个 UITableViewCell 并禁用此 mapView 上的所有用户事件,但仍然可以单击单元格。但是,此 mapView(即使我将 subview 发送回)正在拦
我们即将获得 Java EE6(使用 Glassfish v3 作为引用实现)。计划发布时间为 12 月 9 日。虽然仍有相当多的公司正在努力将他们的代码库从早期版本迁移到 EE5,但我们处于开始开发
为什么(在 WPF、C#、 Entity Framework 中)将 ListBox 绑定(bind)到在 ObjectSet 上创建的 ObservableCollection(来自 Entity框
在 hibernate 中使用 @NamedQuery 而不是 @NamedNativeQuery 有什么好处,反之亦然。我无法发现确切的区别或在什么情况下我们应该使用 @NamedQuery 而不是
在 Dart 中,检查值是否为 == null似乎类似于检查它是否is Null .为什么前者更可取? 最佳答案 这是您正在进行的比较类型。在 == null ,您正在将对象/原始对象与 null 进
我使用的是 Java 1.6。我有一组项目,每个项目都有一个名称和一组组件。每个组件也有一个名称。 Set Class Item String name Set Class Compo
如果我想在我的应用程序中支持脚本,是否 scriptcs提供比仅使用普通 Vanilla 的任何特殊优势 Roslyn脚本引擎? 最佳答案 不幸的是,目前还没有太多关于托管 scriptcs 的文档,
我正在我的应用程序中使用 Struts 和 Spring jdbc 模板。 我必须在我们的代码中使用 Hibernate 模板。 谁能告诉我为什么要使用 Hibernate 模板? 使用 Spring
我是一名优秀的程序员,十分优秀!