【问题标题】:Hive connections蜂巢连接
【发布时间】:2012-07-20 12:39:08
【问题描述】:

嘿,我是 hadoop 和 hive 的新手。我的应用程序现在无法处理多个连接。当连接数增加(超过 4 个)时,它会变慢。哪位大神能看出来。代码如下。

public static void setupDriver(String connectURI) throws Exception {

    ObjectPool connectionPool = new GenericObjectPool(null);
    ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(
            connectURI, username, password);
    @SuppressWarnings("unused")
    PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(
            connectionFactory, connectionPool, null, null, false, true);
    Class.forName(poolingDriver);
    PoolingDriver driver = (PoolingDriver) DriverManager.getDriver(poolConnection);
    driver.registerPool(poolName, connectionPool);
}



stmt = connection.createStatement();
String queryString = "select feed_date,count(feed_date) from twitter_stats where tweet like '%" + searchRequest.getWord() + "%' ";
if (null != searchRequest.getFromDate()) {
    queryString += "and feed_date >= '" + searchRequest.getFromDate() + "' ";
} 

【问题讨论】:

  • 你确定麻烦来自那里吗?我不是 Hive 专家,但从我的数据库经验来看,这很可能是查询概念问题,而不是 java 问题。您能发表您的要求吗?
  • stmt = connection.createStatement(); String queryString = "select feed_date,count(feed_date) from twitter_stats where tweet like '%" + searchRequest.getWord() + "%' "; if (null != searchRequest.getFromDate()) { queryString += "and feed_date >= '" + searchRequest.getFromDate() + "' "; }

标签: sql hadoop cloud hive


【解决方案1】:

你真的不应该使用以 % 开头的 LIKE 条件。在大多数情况下,这会导致性能问题! 尝试压制它,然后告诉我们它是否能解决您的问题。

这里有一些线索:LIKE work-around in SQL (Performance issues),即使不处理这个主题。

【讨论】:

  • 感谢 Jean,它确实提高了速度。但连接问题依然存在。
  • 不要犹豫,发布您的错误堆栈。你想过关闭你的连接吗?
  • 是的,连接已正确关闭。 java中是否还有其他可以处理多个连接的类?
  • @NajeebThalakkatt 我不这么认为......但我又不是 Hadoop 专家:/
【解决方案2】:

连接的处理取决于 Hive Metastore Server。它应该安装在强大的服务器上,或者如果您在虚拟机上工作,请尝试增加 vm 的内存或 cpu。 另外,尝试查看 Hive Metastore 服务器日志,是否存在内存或性能错误。(?) 或者,您可以在 CDH 5.3.x 及更高版本支持的多服务器环境中使用 Hive Metastore Server 的两个实例。

【讨论】:

    猜你喜欢
    • 2015-05-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-13
    • 2016-09-20
    • 1970-01-01
    • 1970-01-01
    • 2019-01-12
    相关资源
    最近更新 更多