0

クエリは次のようになります..

select deviceid,devicename,totalbytes,'Others' as protocolgroup from (
    select d.deviceid,d.name as devicename,sum(bytes) as totalbytes from tblmainallowedtraffic_5min  b,tbldevice d
    WHERE (  B.APPID IN ('C070100126-VW717U','C018600068-GEF3O6','C045701665-9B6S1A','C026100710-36NPQE','C016801597-V1Z8IM') ) 
    and proto_group not in (select proto_group from (select proto_group,sum(bytes) from
    TBLMAINALLOWEDTRAFFIC_5MIN B WHERE (  B.APPID IN ('C070100126-VW717U','C018600068-GEF3O6','C045701665-9B6S1A',
    'C026100710-36NPQE','C016801597-V1Z8IM') ) AND "5mintime" >='04-APR-12 12.00.00.000000 AM' AND
    "5mintime" <='04-APR-12 11.59.59.000000 PM' group by proto_group order by sum(bytes) desc ) WHERE ROWNUM <=5 )
    AND B.APPID=D.APPID AND "5mintime" >='04-APR-12 12.00.00.000000 AM' AND "5mintime" <='04-APR-12 11.59.59.000000 PM' 
    GROUP BY D.APPID,D.DEVICEID,D.NAME)
    order by protocolgroup desc, totalbytes desc

計画の説明では、それは..

3 - フィルター ( NOT EXISTS (実行不可能))

上記のクエリを静的な内部クエリの結果で変更すると、出力が速くなります:

 select deviceid,devicename,totalbytes,'Others' as protocolgroup from (
    select d.deviceid,d.name as devicename,sum(bytes) as totalbytes from tblmainallowedtraffic_5min  b,tbldevice d
    WHERE (  B.APPID IN ('C070100126-VW717U','C018600068-GEF3O6','C045701665-9B6S1A','C026100710-36NPQE','C016801597-V1Z8IM') ) 
    and proto_group not in ('POP3','HTTP Request Response','Web','GET HTTP DATA MORE THAN 976 KB','SMTP' )
    AND B.APPID=D.APPID AND "5mintime" >='04-APR-12 12.00.00.000000 AM' AND "5mintime" <='04-APR-12 11.59.59.000000 PM' 
    GROUP BY D.APPID,D.DEVICEID,D.NAME)
    order by protocolgroup desc, totalbytes desc

そのため、存在しない句が同じテーブルに適用されると問題が発生します..
これについて何か考えを教えてください。

4

1 に答える 1

0

編集:新しい答え:

アンチ結合を試してください:

SELECT deviceid,
  devicename,
  totalbytes,
  'Others' AS protocolgroup
FROM
  (SELECT d.deviceid,
    d.name     AS devicename,
    SUM(bytes) AS totalbytes
  FROM tblmainallowedtraffic_5min b,
    tbldevice d
  LEFT OUTER JOIN 
    (SELECT proto_group
    FROM
      (SELECT proto_group,
        SUM(bytes)
       FROM TBLMAINALLOWEDTRAFFIC_5MIN B
       WHERE ( B.APPID IN ('C070100126-VW717U','C018600068-GEF3O6','C045701665-9B6S1A', 'C026100710-36NPQE','C016801597-V1Z8IM') )
         AND "5mintime"  >='04-APR-12 12.00.00.000000 AM'
         AND "5mintime"  <='04-APR-12 11.59.59.000000 PM'
       GROUP BY proto_group
       ORDER BY SUM(bytes) DESC
      )
    WHERE ROWNUM <=5
    ) e ON b.proto_group = e.proto_group
  WHERE ( B.APPID     IN ('C070100126-VW717U','C018600068-GEF3O6','C045701665-9B6S1A','C026100710-36NPQE','C016801597-V1Z8IM') )
  AND e.proto_group is null
  AND B.APPID     =D.APPID
  AND "5mintime" >='04-APR-12 12.00.00.000000 AM'
  AND "5mintime" <='04-APR-12 11.59.59.000000 PM'
  GROUP BY D.APPID,
    D.DEVICEID,
    D.NAME
  )
ORDER BY protocolgroup DESC,
  totalbytes DESC
于 2012-04-05T10:21:06.550 に答える