Guest User

Untitled

a guest
Jun 24th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.12 KB | None | 0 0
  1. explain analyze SELECT t4.detectorid, t4.description, t4.count, total,
  2. CAST(t4.count AS NUMERIC) / CAST(total AS NUMERIC) * 100.0 AS percentage
  3. FROM (SELECT t1.detectorid, description, count(*) as count
  4. from loopdata_2007_01_01 t1, loop_status
  5. where t1.status = loop_status.status
  6. GROUP BY t1.detectorid, description) t4,
  7. (SELECT detectorid, COUNT(*) AS total
  8. FROM loopdata_2007_01_01 t2
  9. GROUP BY detectorid
  10. ORDER BY detectorid) t3
  11. WHERE t4.detectorid = t3.detectorid
  12. ORDER BY t4.detectorid, t4.description, t3.total
  13. ;
  14. QUERY PLAN
  15. -----------------------------------------------------------------------------------------------------------------------------------------------------------------------
  16. Sort (cost=710083.07..711078.47 rows=398161 width=38) (actual time=22667.435..22668.159 rows=1386 loops=1)
  17. Sort Key: t1.detectorid, loop_status.description, t3.total
  18. Sort Method: quicksort Memory: 198kB
  19. -> Merge Join (cost=602939.70..651271.14 rows=398161 width=38) (actual time=17907.248..22665.778 rows=1386 loops=1)
  20. Merge Cond: (t1.detectorid = t3.detectorid)
  21. -> GroupAggregate (cost=544650.66..573487.36 rows=126200 width=22) (actual time=14246.234..18997.411 rows=1386 loops=1)
  22. -> Sort (cost=544650.66..551465.46 rows=2725920 width=22) (actual time=14242.307..17137.123 rows=2725920 loops=1)
  23. Sort Key: t1.detectorid, loop_status.description
  24. Sort Method: external merge Disk: 50000kB
  25. -> Hash Join (cost=45.33..85556.32 rows=2725920 width=22) (actual time=0.076..5438.041 rows=2725920 loops=1)
  26. Hash Cond: (t1.status = loop_status.status)
  27. -> Seq Scan on loopdata_2007_01_01 t1 (cost=0.00..44622.20 rows=2725920 width=4) (actual time=0.032..1685.744 rows=2725920 loops=1)
  28. -> Hash (cost=25.70..25.70 rows=1570 width=22) (actual time=0.030..0.030 rows=6 loops=1)
  29. -> Seq Scan on loop_status (cost=0.00..25.70 rows=1570 width=22) (actual time=0.016..0.021 rows=6 loops=1)
  30. -> Materialize (cost=58289.03..58303.23 rows=631 width=10) (actual time=3660.990..3663.363 rows=1386 loops=1)
  31. -> Subquery Scan t3 (cost=58289.03..58296.92 rows=631 width=10) (actual time=3660.983..3662.162 rows=631 loops=1)
  32. -> Sort (cost=58289.03..58290.61 rows=631 width=2) (actual time=3660.980..3661.429 rows=631 loops=1)
  33. Sort Key: t2.detectorid
  34. Sort Method: quicksort Memory: 54kB
  35. -> HashAggregate (cost=58251.80..58259.69 rows=631 width=2) (actual time=3659.995..3660.390 rows=631 loops=1)
  36. -> Seq Scan on loopdata_2007_01_01 t2 (cost=0.00..44622.20 rows=2725920 width=2) (actual time=0.044..1633.167 rows=2725920 loops=1)
  37. Total runtime: 22686.007 ms
  38. (22 rows)
Add Comment
Please, Sign In to add comment