php - Cassandra 数据统计 | 超时异常
问题描述
我对 cassandra 有疑问,我有以下错误。我链接图片
代码语法:
public function find($db_table = null, $db_id = null) {
$filter = "";
$return = array();
$cluster = $this->cluster();
$session = $cluster->connect($this->keyspace);
if(isset($db_table)) {
$filter .= " WHERE db_table like '%".$db_table."%' ";
if($db_id != null) {
$filter .= " AND db_id = '".$db_id."' ALLOW FILTERING";
}
}
$query = new Cassandra\SimpleStatement("SELECT * FROM ".$this->keyspace.".log $filter;");
$result = $session->executeAsync($query);
$rows = $result->get();
解决方案
- 除非您知道自己在做什么,否则不应使用“允许过滤”。
- SELECT * FROM prod.log WHERE db_id = 13913 AND db_table LIKE '%%' product LIMIT 5000 超时,因为您似乎在数据库中有很多条目并且允许过滤正在执行全表扫描。
- 您应该调整表设计以匹配您的查询。
推荐阅读
- java - libimobiledevice 返回奇怪的字符
- java - Java Json String 提取数字并替换特定文本
- sql - 如何在 ORACLE 中对用户模式中的所有表运行单个查询
- c# - Microsoft onedrive:使用 API 密钥创建文件夹,无需登录
- javascript - 用于呈现局部视图的 JavaScript 按钮
- java - 我在 mongodb 服务器中有一个 json 对象,我想在 android 的 textview 中显示它该怎么做
- c - C 语言中的类型转换数据打印错误
- php - 查询生成器在线工具的原始查询
- asp.net - 如何在锚点周围添加“if 条件”以检查字段值是否为空?
- python - 根据答案统计调查的票数