2017-02-23 41 views
1

请耐心等待我对以下技术缺乏了解。对于Hbase,在MySQL中是否有像EXPLAIN这样的函数?

我们做了一堆查询(60k查询),过去需要45分钟才能完成。现在,大约相同的数量需要3小时20分钟。编码它的人不在这里了,所以我们不完全知道可能发生了什么。

我的团队中的领导让我看看是否有像SQLAIN中的EXPLAIN这样的命令来查看hbase在搜索rowkey时如何通过区域。我试图谷歌,但它看起来并不像。 Hbase中是否有一些命令与SQL中的EXPLAIN类似?

如果对问题有帮助,我们正在存储时间序列数据。该rowkey的格式为:

hashOfName_elementName_epochtime 

我们认为HBase的应该知道,从我们查询,因此不会采取这么长的时间查询时间的ElementName以避免地区,但我们还不能确定。希望这个命令存在,这样我们就可以看到Hbase是如何查询的,所以我们知道我们是需要重新设计模式还是重做rowkey,或者它是当前存储的影响速度的数据。

更新:我们查询元素列表的时间范围。数据每分钟保存一次,用于hbase中的元素。当我们进行扫描时,我们可以扫描1小时或1天。 我可以从调试信息中看到,当我们扫描时,我们扫描那段时间。

e.g. hash_elementName_timestamp. timestamp is a 10 digit epoch time 
hash = murmur3_128 hash function of the element name 
154_eee_0000000000 
154_eee_0000000060 
154_eee_0000000120 
... 
.. 
154_eee_0000003600 

167_aaa_0000000000 
167_aaa_0000000060 
... 
... 
167_aaa_0000003600 

这是我们从扫描方法的代码片段:

public Map<String,String> scan(String name, String columnFamilyName, String columnName, long start, long end, 
boolean reversed, int limit) throws IOException { 

Map<String,String> m = new LinkedHashMap<String,String>(); 

Table table = null; 
ResultScanner scanner = null; 

try { 

    String hash = makeHash(name,fType.getNumberOfRegion()); 
    String key = hash + "_" + name +"_"; 

    Scan scan; 
    if (reversed) { 
     //swap the start and end keys when reversed 
     scan = new Scan(Bytes.toBytes(key + end),Bytes.toBytes(key + start)); 
     scan.setReversed(true); 
    } else { 
     scan = new Scan(Bytes.toBytes(key + start),Bytes.toBytes(key + end)); 
    } 
    scan.addColumn(Bytes.toBytes(columnFamilyName), Bytes.toBytes(columnName)); 
    table = fCconnection.getTable(fTablename); 
    scanner = table.getScanner(scan); 

    int count = 0; 
    for (Result result = scanner.next(); result != null; result = scanner.next()) { 
     //if a limit was set, then only scan until we hit the limit 
     if (limit > 0 && count > limit) { 
      break; 
     } 

     m.put(Bytes.toString(result.getRow()), Bytes.toString((result.getValue(Bytes.toBytes(columnFamilyName), Bytes.toBytes(columnName))))); 
     count++; 
    } 
+0

根据我有限的知识,在hbase中没有'explain“。也是'Wide Column Store'的Cassandra具有此功能:http://www.datastax.com/dev/博客/ tracing-in-cassandra-1-2 –

回答

0

嘛HBase的不是SQL。所以你没有解释。就你而言,你需要研究查询的行为方式并开始调整。我知道它是一个非常高层次的声明。

您提到您有疑问。你是如何执行它们的?请添加详细信息 - 更多信息

+0

我编辑了这个问题。希望能够提供更多关于我们如何查询的信息。我还会在阅读代码后尝试添加代码片段 – Classified

相关问题