najeeb
najeeb

Reputation: 813

Hive connections

Hai i am new to hadoop and hive. My app cannot handle multiple connections now. When the number connections increasing(more than 4) it gets slow. Can any one figure it out.The code is given below.

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() + "' ";
} 

Upvotes: 2

Views: 1014

Answers (2)

HakkiBuyukcengiz
HakkiBuyukcengiz

Reputation: 419

Handling of connections is up to the Hive Metastore Server. It should be installed on a strong server, or if you work on your virtual machine, try to increase your vm's memory or cpu. Also, try to look at Hive Metastore server logs, whether there is a memory or performance error.(?) Or, you can use two instance of Hive Metastore Server, in a multiple server environment, which is supported by CDH 5.3.x and upper.

Upvotes: 0

Jean-Rémy Revy
Jean-Rémy Revy

Reputation: 5677

You really should not use a LIKE condition which is starting by %. In most case, this will lead to performance trouble ! Try to suppress it, and then tell us if it solve your issue.

There is some clues here : LIKE work-around in SQL (Performance issues), even if don't deal with this subject.

Upvotes: 1

Related Questions