在phoenix中运行五个选择查询后,将两个表连接起来并获得100条记录

时间:2019-05-17 12:46:23

标签: performance hbase phoenix

如何在phoenix中执行五次查询后仅获得100条记录?  我试图用Java中的5个查询从phoenix获取数据,但是我只需要获取100条记录。?

这些是查询

query = "SELECT /*+ USE_SORT_MERGE_JOIN*/ S.\"co_relation_id\",S.\"errorInfo\",S.\"msgTxt\",S.\"timestamp\",S.\"clientId\" ,S.\"clientName\",S.\"localFileName\","+
                "E.\"remoteFileName\",E.\"msgTxt\",E.\"nodeId\",E.\"status\",E.\"direction\",E.\"errorInfo\",E.\"timestamp\",E.\"duration\",S.\"duration\", S.\"successValue\", E.\"successValue\" FROM "+
                "FILEGPS.ORDER_EVENTS_DATA1 S,FILEGPS.ORDER_EVENTS_DATA1 E WHERE S.\"co_relation_id\"=E.\"co_relation_id\" AND S.\"msgTxt\"='Start' AND E.\"msgTxt\"='Stop' AND S.\"nodeId\" != '1/M' AND E.\"nodeId\" != 'M/1' AND S.\"sub_co_relation_id\" IS NULL  ";                            
        subProcQuery ="SELECT /*+ USE_SORT_MERGE_JOIN*/ S.\"co_relation_id\",S.\"msgTxt\",S.\"timestamp\",S.\"clientId\" ,S.\"clientName\",S.\"localFileName\","
                +"P.\"remoteFileName\",P.\"msgTxt\",P.\"nodeId\",P.\"status\",P.\"direction\",P.\"errorInfo\",P.\"timestamp\",P.\"duration\",S.\"successValue\" ,P.\"successValue\""
                +"FROM FILEGPS.ORDER_EVENTS_DATA1 S,FILEGPS.ORDER_EVENTS_DATA1 P WHERE S.\"co_relation_id\"=P.\"co_relation_id\" AND S.\"msgTxt\"='Start' AND P.\"msgTxt\"='Process'  "
                +" AND S.\"nodeId\" != '1/M' AND P.\"nodeId\" != 'M/1' AND S.\"sub_co_relation_id\" IS NULL ";  

        dummySToSQuery = "SELECT /*+ USE_SORT_MERGE_JOIN*/ S.\"co_relation_id\" FROM FILEGPS.ORDER_EVENTS_DATA1 S,FILEGPS.ORDER_EVENTS_DATA1 E  WHERE S.\"msgTxt\"='Start' AND E.\"msgTxt\"='Stop' AND "
                + " S.\"co_relation_id\"=E.\"co_relation_id\" ";
        dummySToPQuery = "SELECT /*+ USE_SORT_MERGE_JOIN*/ S.\"co_relation_id\" FROM FILEGPS.ORDER_EVENTS_DATA1 S,FILEGPS.ORDER_EVENTS_DATA1 P  WHERE S.\"msgTxt\"='Start' AND P.\"msgTxt\"='Process' AND "
                + " S.\"co_relation_id\"=P.\"co_relation_id\" ";

        query = getModifiedQuery(query,beanStoEDTO);

        subProcQuery = getModifiedQuery(subProcQuery,beanStoPDTO);

        subProcQuery = subProcQuery +" AND S.\"co_relation_id\" NOT IN(SELECT S1.\"co_relation_id\" FROM FILEGPS.ORDER_EVENTS_DATA1 S1,FILEGPS.ORDER_EVENTS_DATA1 E WHERE "
                +" S1.\"co_relation_id\"=E.\"co_relation_id\" AND S1.\"msgTxt\"='Start' AND E.\"msgTxt\"='Stop') ";
        //startQuery = "SELECT \"co_relation_id\",\"msgTxt\",\"timestamp\",\"clientId\" ,\"clientName\",\"localFileName\",\"remoteFileName\" ,\"nodeId\",\"duration\",\"errorInfo\",\"status\" FROM FILEGPS.ORDER_EVENTS_DATA1 WHERE \"msgTxt\" ='Start' AND \"nodeId\" != '1/M' ";
        startQuery="SELECT  * FROM FILEGPS.ORDER_EVENTS_DATA1 WHERE \"msgTxt\" ='Start' AND \"nodeId\" != '1/M' ";

        //startQuery=getModifiedQuery(startQuery,beanStoEDTO);
        //oneToM = "SELECT \"co_relation_id\",\"msgTxt\",\"timestamp\",\"clientId\" ,\"clientName\",\"localFileName\",\"remoteFileName\" ,\"nodeId\",\"duration\",\"errorInfo\",\"status\"  FROM FILEGPS.ORDER_EVENTS_DATA1 WHERE \"nodeId\" = '1/M' AND \"sub_co_relation_id\" IS NULL ";  
        oneToM = "SELECT *  FROM FILEGPS.ORDER_EVENTS_DATA1 WHERE \"nodeId\" = '1/M' AND \"sub_co_relation_id\" IS NULL ";  

        //manyToOne = "SELECT \"co_relation_id\",\"msgTxt\",\"timestamp\",\"clientId\" ,\"clientName\",\"localFileName\",\"remoteFileName\" ,\"nodeId\",\"duration\",\"errorInfo\",\"status\"  FROM FILEGPS.ORDER_EVENTS_DATA1 WHERE \"nodeId\" = 'M/1' ";
        manyToOne = "SELECT *  FROM FILEGPS.ORDER_EVENTS_DATA1 WHERE \"nodeId\" = 'M/1' ";

        //manyToOne=getModifiedQuery(manyToOne,beanStoEDTO);
        reProcessQueryStop = "SELECT /*+ USE_SORT_MERGE_JOIN*/ S.\"co_relation_id\",S.\"msgTxt\",S.\"timestamp\",S.\"clientId\" ,S.\"clientName\",S.\"localFileName\"," 
                +"E.\"remoteFileName\",E.\"msgTxt\",E.\"nodeId\",E.\"status\",E.\"direction\",E.\"errorInfo\",S.\"errorInfo\",P.\"errorInfo\","
                + "E.\"timestamp\",E.\"duration\",S.\"duration\", S.\"successValue\", E.\"successValue\" FROM FILEGPS.ORDER_EVENTS_DATA1 S,FILEGPS.ORDER_EVENTS_DATA1 P,FILEGPS.ORDER_EVENTS_DATA1 E  WHERE S.\"msgTxt\"='Start' AND E.\"msgTxt\"='Stop' AND P.\"msgTxt\"='Reprocess' AND "
                + " S.\"co_relation_id\"=E.\"co_relation_id\" AND S.\"co_relation_id\"=P.\"co_relation_id\" ";

        reProcessQueryRePrcess = "SELECT /*+ USE_SORT_MERGE_JOIN*/ S.\"co_relation_id\",S.\"msgTxt\",S.\"timestamp\",S.\"clientId\" ,S.\"clientName\",S.\"localFileName\","
                +"P.\"remoteFileName\",P.\"msgTxt\",P.\"nodeId\",P.\"status\",P.\"direction\",P.\"errorInfo\",S.\"errorInfo\",P.\"timestamp\",P.\"duration\",S.\"successValue\" ,P.\"successValue\""
                +"FROM FILEGPS.ORDER_EVENTS_DATA1 S,FILEGPS.ORDER_EVENTS_DATA1 P WHERE S.\"co_relation_id\"=P.\"co_relation_id\" AND S.\"msgTxt\"='Start' AND P.\"msgTxt\"='Reprocess'  "
                +" AND S.\"nodeId\" != '1/M' AND P.\"nodeId\" != 'M/1' ";               
        reProcessQueryProcess = "SELECT /*+ USE_SORT_MERGE_JOIN*/  S.\"co_relation_id\",S.\"msgTxt\",S.\"timestamp\",S.\"clientId\" ,S.\"clientName\",S.\"localFileName\","
                +"P.\"remoteFileName\",P.\"msgTxt\",P.\"nodeId\",P.\"status\",P.\"direction\",P.\"errorInfo\",S.\"errorInfo\",R.\"errorInfo\",P.\"timestamp\",P.\"duration\",S.\"successValue\" ,P.\"successValue\""
                +"FROM FILEGPS.ORDER_EVENTS_DATA1 S,FILEGPS.ORDER_EVENTS_DATA1 P,FILEGPS.ORDER_EVENTS_DATA1 R WHERE S.\"co_relation_id\"=P.\"co_relation_id\" AND S.\"msgTxt\"='Start' "
                + "AND S.\"co_relation_id\"=R.\"co_relation_id\" AND P.\"msgTxt\"='Process' AND R.\"msgTxt\"='Reprocess' "
                +" AND S.\"nodeId\" != '1/M' AND P.\"nodeId\" != 'M/1' ";

        dummyRepSToSQuery = "SELECT /*+ USE_SORT_MERGE_JOIN*/ S.\"co_relation_id\" FROM FILEGPS.ORDER_EVENTS_DATA1 S,FILEGPS.ORDER_EVENTS_DATA1 P,FILEGPS.ORDER_EVENTS_DATA1 E  WHERE S.\"msgTxt\"='Start' AND E.\"msgTxt\"='Stop' AND P.\"msgTxt\"='Reprocess' AND "
                + " S.\"co_relation_id\"=E.\"co_relation_id\" AND S.\"co_relation_id\"=P.\"co_relation_id\" ";
        dummyRepSToPQuery = "SELECT /*+ USE_SORT_MERGE_JOIN*/  S.\"co_relation_id\" FROM FILEGPS.ORDER_EVENTS_DATA1 S,FILEGPS.ORDER_EVENTS_DATA1 P,FILEGPS.ORDER_EVENTS_DATA1 R WHERE S.\"co_relation_id\"=P.\"co_relation_id\" AND S.\"msgTxt\"='Start' "
                + "AND S.\"co_relation_id\"=R.\"co_relation_id\" AND P.\"msgTxt\"='Process' AND R.\"msgTxt\"='Reprocess' "
                +" AND S.\"nodeId\" != '1/M' AND P.\"nodeId\" != 'M/1' ";

0 个答案:

没有答案