Using SORT of WINDOW and temp

Hi all
I have the following query.

Select u_bipid as BIP_ID,
min (best_tel) as Telefon,
min (best_fax) as Fax,
min (best_hrjahr) as hrjahr,
min (best_hrnr) as hrnr,
min (best_hrort) as hrort,
min (best_main) as main_seqid,
min (best_email) as e-mail,
min (best_www) as HOME page,
min (best_UMSATZWERT) as UMSATZWERT,
min (best_GRUEND) as GRUENDUNG,
min (best_MITARBWERT) as MITARBWERT,
min (best_HRART) as HRARTCODIERT,
min (best_Q01) as Q01,
min (best_Q02) as Q02,
min (best_Q03) as Q03,
min (best_Q04) as Q04,
min (best_Q05) as Q05,
min (best_Q06) as Q06,
min (best_Q07) as Q07,
min (best_Q08) as Q08,
min (best_Q09) as Q09,
min (best_Q10) as Q10,
min (best_Q11) as Q11,
min (best_Q12) as Q12,
min (best_Q13) as Q13,
min (best_Q14) as Q14,
min (best_Q15) as Q15,
min (best_Q16) as Q16,
min (best_Q17) as Q17,
min (best_Q18) as Q18,
min (best_Q19) as Q19,
min (best_Q20) as Q20,
min (decode(best_tel_level,'N',0,1)) as phonelevel,
min (best_kgs22) as kgs22
Of
(select first_value (seqid) over (partition by u_bipid order (case when ACXKGS22 is null or ACXFIRMA is null then 1 or 0 end), RTYPE, seqsourcedate desc, ORGSTATUS, (PunkteName + PunkteAddress + PunkteContact + PunkteImpressum + PunkteBranche) / / desc, decode (u_seqsourceid, 14,0,16,1,1, 2, 2, 3, 7, 3, 3, 3, null, 5, 4), seqid desc) as best_main,)
FIRST_VALUE (ACXPHONE) over (partition by order of u_bipid to decode (length (ACXPHONE), 0, 1, null, 2, 0), RTYPE, seqsourcedate desc, decode (u_seqsourceid, 14,0,16,1,1, 3, 2, 2, 7, 2, 3, 2, null, 5, 4), seqid desc) as best_tel,
FIRST_VALUE (ACXPHONElevel) over (partition by order of u_bipid to decode (length (ACXPHONE), 0, 1, null, 2, 0), RTYPE, seqsourcedate desc, decode (u_seqsourceid, 14,0,16,1,1, 3, 2, 2, 7, 2, 3, 2, null, 5, 4), seqid desc) as best_tel_level,
FIRST_VALUE (ACXFAX) over (partition by order of u_bipid to decode (length (ACXFAX), 0, 1, null, 2, 0), RTYPE, seqsourcedate desc, decode (u_seqsourceid, 14,0,16,1,1, 3, 2, 2, 7, 2, 3, 2, null, 5, 4), seqid desc) as best_fax,
FIRST_VALUE (ORGHRJAHR) over (partition by order of u_bipid to decode (length (ORGHRJAHR), 0, 1, null, 2, 0) + decode (length (orghrnr), 0, 1, null, 2, 0) + decode (length (ORGHRORT), 0, 1, null, 2, 0), RTYPE, seqsourcedate desc, decode (u_seqsourceid, 14,0,16,1,1, 2, 2, 3, 7, 3, 3, 3, null, 5, 4), seqid desc) as best_hrjahr,
FIRST_VALUE (orghrnr) over (partition by order of u_bipid to decode (length (ORGHRJAHR), 0, 1, null, 2, 0) + decode (length (orghrnr), 0, 1, null, 2, 0) + decode (length (ORGHRORT), 0, 1, null, 2, 0), RTYPE, seqsourcedate desc, decode (u_seqsourceid, 14,0,16,1,1, 2, 2, 3, 7, 3, 3, 3, null, 5, 4), seqid desc) as best_hrnr,
FIRST_VALUE (ORGHRORT) over (partition by order of u_bipid to decode (length (ORGHRJAHR), 0, 1, null, 2, 0) + decode (length (orghrnr), 0, 1, null, 2, 0) + decode (length (ORGHRORT), 0, 1, null, 2, 0), RTYPE, seqsourcedate desc, decode (u_seqsourceid, 14,0,16,1,1, 2, 2, 3, 7, 3, 3, 3, null, 5, 4), seqid desc) as best_hrort,
FIRST_VALUE (ORGEMAIL) over (partition by order of u_bipid to decode (length (ORGEMAIL), 0, 1, null, 2, 0), RTYPE, seqsourcedate desc, decode (u_seqsourceid, 14,0,16,1,1, 2, 2, 3, 7, 3, 3, 3, null, 5, 4), seqid desc) as best_email,
FIRST_VALUE (ORGINTERNET) over (partition by order of u_bipid to decode (length (ORGINTERNET), 0, 1, null, 2, 0), RTYPE, seqsourcedate desc, decode (u_seqsourceid, 14,0,16,1,1, 2, 2, 3, 7, 3, 3, 3, null, 5, 4), seqid desc) as best_www,
FIRST_VALUE (ORGUMSATZ) over (partition by order of u_bipid to decode (length (ORGUMSATZ), 0, 1, null, 2, 0), RTYPE, seqsourcedate desc, decode (u_seqsourceid, 14,0,16,1,1, 2, 2, 3, 7, 3, 3, 3, null, 5, 4), seqid desc) as best_UMSATZWERT,
FIRST_VALUE (ORGGRUENDJAHR) over (partition by order of u_bipid to decode (length (ORGGRUENDJAHR), 0, 1, null, 2, 0), RTYPE, seqsourcedate desc, decode (u_seqsourceid, 14,0,16,1,1, 2, 2, 3, 7, 3, 3, 3, null, 5, 4), seqid desc) as best_GRUEND,
FIRST_VALUE (ORGMITARBEITER) over (partition by order of u_bipid to decode (length (ORGMITARBEITER), 0, 1, null, 2, 0), RTYPE, seqsourcedate desc, decode (u_seqsourceid, 14,0,16,1,1, 2, 2, 3, 7, 3, 3, 3, null, 5, 4), seqid desc) as best_MITARBWERT,
FIRST_VALUE (ORGHRART) over (partition by order of u_bipid to decode (length (ORGHRART), 0, 1, null, 2, 0), RTYPE, seqsourcedate desc, decode (u_seqsourceid, 14,0,16,1,1, 2, 2, 3, 7, 3, 3, 3, null, 5, 4), seqid desc) as best_HRART,
FIRST_VALUE (decode(seqsourceid,'01',ORGSTATUS,null)) over (partition by order of u_bipid to decode (seqsourceid, '01 ', '0', 2'), decode (length (ORGSTATUS), 0, 1, null, 2, 0), RTYPE, seqsourcedate desc, seqid desc) as best_Q01,
FIRST_VALUE (decode(seqsourceid,'02',ORGSTATUS,null)) over (partition by order of u_bipid to decode (seqsourceid, '02 ', '0', 2'), decode (length (ORGSTATUS), 0, 1, null, 2, 0), RTYPE, seqsourcedate desc, seqid desc) as best_Q02,
FIRST_VALUE (decode(seqsourceid,'03',ORGSTATUS,null)) over (partition by order of u_bipid to decode (seqsourceid, '03 ', '0', 2'), decode (length (ORGSTATUS), 0, 1, null, 2, 0), RTYPE, seqsourcedate desc, seqid desc) as best_Q03,
FIRST_VALUE (decode(seqsourceid,'04',ORGSTATUS,null)) over (partition by order of u_bipid to decode (seqsourceid, '04 ', '0', 2'), decode (length (ORGSTATUS), 0, 1, null, 2, 0), RTYPE, seqsourcedate desc, seqid desc) as best_Q04,
FIRST_VALUE (decode(seqsourceid,'05',ORGSTATUS,null)) over (partition by order of u_bipid to decode (seqsourceid, '05 ', '0', 2'), decode (length (ORGSTATUS), 0, 1, null, 2, 0), RTYPE, seqsourcedate desc, seqid desc) as best_Q05,
FIRST_VALUE (decode(seqsourceid,'06',ORGSTATUS,null)) over (partition by order of u_bipid to decode (seqsourceid, '06 ', '0', 2'), decode (length (ORGSTATUS), 0, 1, null, 2, 0), RTYPE, seqsourcedate desc, seqid desc) as best_Q06,
FIRST_VALUE (decode(seqsourceid,'07',ORGSTATUS,null)) over (partition by order of u_bipid to decode (seqsourceid, '07 ', '0', 2'), decode (length (ORGSTATUS), 0, 1, null, 2, 0), RTYPE, seqsourcedate desc, seqid desc) as best_Q07,
FIRST_VALUE (decode(seqsourceid,'08',ORGSTATUS,null)) over (partition by order of u_bipid to decode (seqsourceid, '08 ', '0', 2'), decode (length (ORGSTATUS), 0, 1, null, 2, 0), RTYPE, seqsourcedate desc, seqid desc) as best_Q08,
FIRST_VALUE (decode(seqsourceid,'09',ORGSTATUS,null)) over (partition by order of u_bipid to decode (seqsourceid, '09 ', '0', 2'), decode (length (ORGSTATUS), 0, 1, null, 2, 0), RTYPE, seqsourcedate desc, seqid desc) as best_Q09,
FIRST_VALUE (decode(seqsourceid,'10',ORGSTATUS,null)) over (partition by order of u_bipid to decode (seqsourceid, '10 ', '0', 2'), decode (length (ORGSTATUS), 0, 1, null, 2, 0), RTYPE, seqsourcedate desc, seqid desc) as best_Q10,
FIRST_VALUE (decode(seqsourceid,'11',ORGSTATUS,null)) over (partition by order of u_bipid to decode (seqsourceid, '11 ', '0', 2'), decode (length (ORGSTATUS), 0, 1, null, 2, 0), RTYPE, seqsourcedate desc, seqid desc) as best_Q11,
FIRST_VALUE (decode(seqsourceid,'12',ORGSTATUS,null)) over (partition by order of u_bipid to decode (seqsourceid, '12 ', '0', 2'), decode (length (ORGSTATUS), 0, 1, null, 2, 0), RTYPE, seqsourcedate desc, seqid desc) as best_Q12,
FIRST_VALUE (decode(seqsourceid,'13',ORGSTATUS,null)) over (partition by order of u_bipid to decode (seqsourceid, '13 ', '0', 2'), decode (length (ORGSTATUS), 0, 1, null, 2, 0), RTYPE, seqsourcedate desc, seqid desc) as best_Q13,
FIRST_VALUE (decode(seqsourceid,'14',ORGSTATUS,null)) over (partition by order of u_bipid to decode (seqsourceid, '14 ', '0', 2'), decode (length (ORGSTATUS), 0, 1, null, 2, 0), RTYPE, seqsourcedate desc, seqid desc) as best_Q14,
FIRST_VALUE (decode(seqsourceid,'15',ORGSTATUS,null)) over (partition by order of u_bipid to decode (seqsourceid, '15 ', '0', 2'), decode (length (ORGSTATUS), 0, 1, null, 2, 0), RTYPE, seqsourcedate desc, seqid desc) as best_Q15,
FIRST_VALUE (decode(seqsourceid,'16',ORGSTATUS,null)) over (partition by order of u_bipid to decode (seqsourceid, '16 ', '0', 2'), decode (length (ORGSTATUS), 0, 1, null, 2, 0), RTYPE, seqsourcedate desc, seqid desc) as best_Q16,
FIRST_VALUE (decode(seqsourceid,'17',ORGSTATUS,null)) over (partition by order of u_bipid to decode (seqsourceid, '17 ', '0', 2'), decode (length (ORGSTATUS), 0, 1, null, 2, 0), RTYPE, seqsourcedate desc, seqid desc) as best_Q17,
FIRST_VALUE (decode(seqsourceid,'18',ORGSTATUS,null)) over (partition by order of u_bipid to decode (seqsourceid, '18 ', '0', 2'), decode (length (ORGSTATUS), 0, 1, null, 2, 0), RTYPE, seqsourcedate desc, seqid desc) as best_Q18,
FIRST_VALUE (decode(seqsourceid,'19',ORGSTATUS,null)) over (partition by order of u_bipid to decode (seqsourceid, '19 ', '0', 2'), decode (length (ORGSTATUS), 0, 1, null, 2, 0), RTYPE, seqsourcedate desc, seqid desc) as best_Q19,
FIRST_VALUE (decode(seqsourceid,'20',ORGSTATUS,null)) over (partition by order of u_bipid to decode (seqsourceid, '20 ', '0', 2'), decode (length (ORGSTATUS), 0, 1, null, 2, 0), RTYPE, seqsourcedate desc, seqid desc) as best_Q20,
FIRST_VALUE (ACXKGS22) over (partition by u_bipid order (case when ACXKGS22 is null or ACXFIRMA is null then 1 or 0 end), RTYPE, seqsourcedate desc, ORGSTATUS, (PunkteName + PunkteAddress + PunkteContact + PunkteImpressum + PunkteBranche) / / desc, decode (u_seqsourceid, 14,0,16,1,1, 2, 2, 3, 7, 3, 3, 3, null, 5, 4), seqid desc) as best_kgs22,
T0.*
between t0 and B2B.tmp_konso_firma
where u_bipid is not null
order of seqid
)
U_bipid group
)

below it is plan execution to this

----------------------------------------------------------------------------------------------------------------------------------
| ID | Operation | Name | Lines | Bytes | TempSpc | Cost (% CPU). Time |
----------------------------------------------------------------------------------------------------------------------------------
| 0 | INSERT STATEMENT. 2078K | 652 M | 5773K (1) | 22:27:13 |
| 1. GROUP SORT BY | 2078K | 652 M | 3692M | 5773K (1) | 22:27:13 |
| 2. VIEW | 7375K | 2314M | 5569K (1) | 21:39:36 |
| 3. SORT ORDER BY | 7375K | 1090M | 3114M | 5569K (1) | 21:39:36 |
| 4. KIND OF WINDOW. 7375K | 1090M | 3114M | 5569K (1) | 21:39:36 |
| 5. KIND OF WINDOW. 7375K | 1090M | 3114M | 5569K (1) | 21:39:36 |
| 6. KIND OF WINDOW. 7375K | 1090M | 3114M | 5569K (1) | 21:39:36 |
| 7. KIND OF WINDOW. 7375K | 1090M | 3114M | 5569K (1) | 21:39:36 |
| 8. KIND OF WINDOW. 7375K | 1090M | 3114M | 5569K (1) | 21:39:36 |
| 9. KIND OF WINDOW. 7375K | 1090M | 3114M | 5569K (1) | 21:39:36 |
| 10. KIND OF WINDOW. 7375K | 1090M | 3114M | 5569K (1) | 21:39:36 |
| 11. KIND OF WINDOW. 7375K | 1090M | 3114M | 5569K (1) | 21:39:36 |
| 12. KIND OF WINDOW. 7375K | 1090M | 3114M | 5569K (1) | 21:39:36 |
| 13. KIND OF WINDOW. 7375K | 1090M | 3114M | 5569K (1) | 21:39:36 |
| 14. KIND OF WINDOW. 7375K | 1090M | 3114M | 5569K (1) | 21:39:36 |
| 15. KIND OF WINDOW. 7375K | 1090M | 3114M | 5569K (1) | 21:39:36 |
| 16. KIND OF WINDOW. 7375K | 1090M | 3114M | 5569K (1) | 21:39:36 |
| 17. KIND OF WINDOW. 7375K | 1090M | 3114M | 5569K (1) | 21:39:36 |
| 18. KIND OF WINDOW. 7375K | 1090M | 3114M | 5569K (1) | 21:39:36 |
| 19. KIND OF WINDOW. 7375K | 1090M | 3114M | 5569K (1) | 21:39:36 |
| 20. KIND OF WINDOW. 7375K | 1090M | 3114M | 5569K (1) | 21:39:36 |
| 21. KIND OF WINDOW. 7375K | 1090M | 3114M | 5569K (1) | 21:39:36 |
| 22. KIND OF WINDOW. 7375K | 1090M | 3114M | 5569K (1) | 21:39:36 |
| 23. KIND OF WINDOW. 7375K | 1090M | 3114M | 5569K (1) | 21:39:36 |
| 24. KIND OF WINDOW. 7375K | 1090M | 3114M | 5569K (1) | 21:39:36 |
| 25. KIND OF WINDOW. 7375K | 1090M | 3114M | 5569K (1) | 21:39:36 |
| 26. KIND OF WINDOW. 7375K | 1090M | 3114M | 5569K (1) | 21:39:36 |
| 27. KIND OF WINDOW. 7375K | 1090M | 3114M | 5569K (1) | 21:39:36 |
| 28. KIND OF WINDOW. 7375K | 1090M | 3114M | 5569K (1) | 21:39:36 |
| 29. KIND OF WINDOW. 7375K | 1090M | 3114M | 5569K (1) | 21:39:36 |
| 30. KIND OF WINDOW. 7375K | 1090M | 3114M | 5569K (1) | 21:39:36 |
| 31. KIND OF WINDOW. 7375K | 1090M | 3114M | 5569K (1) | 21:39:36 |
| 32. KIND OF WINDOW. 7375K | 1090M | 3114M | 5569K (1) | 21:39:36 |
| 33. KIND OF WINDOW. 7375K | 1090M | 3114M | 5569K (1) | 21:39:36 |
| 34. KIND OF WINDOW. 7375K | 1090M | 3114M | 5569K (1) | 21:39:36 |
| 35. KIND OF WINDOW. 7375K | 1090M | 3114M | 5569K (1) | 21:39:36 |
| 36. THE WINDOW BUFFER. 7375K | 1090M | 5569K (1) | 21:39:36 |
| 37. KIND OF WINDOW. 7375K | 1090M | 3114M | 5569K (1) | 21:39:36 |
| * 38 | TABLE ACCESS FULL | TMP_KONSO_FIRMA | 7375K | 1090M | 27832 (2) | 00:06:30 |
----------------------------------------------------------------------------------------------------------------------------------

This request goes most of the time on direct_path_read_temp event but PGA serves almost not at all.
This table TMP_KONSO_FIRMA a date of 1 GB, but this query uses about 60 GB.

Any ideas what is worng with it?
It comes to 10.2.04

Thanks for help

Tags: Database

Similar Questions

Maybe you are looking for

  • Apple Store is not up-to-day - network connection lost

    Hello I have a MacBook Pro with OS X El Capitan installed and allows you to connect to the Bank of the United States, where I bought the laptop. I moved to the New Zealand a few months ago and changed the NZ store, and for the last two weeks that I'm

  • Motorola Service App update

    Motorcycle G (2nd gen) a Motorola Update service app? I see all over the internet that Moto G 'Motorola Update Service' app updated so that it can receive the OTA for Lollipop.

  • HP Mini 311 - HP battery alert - main (internal) (601) - error at startup

    I have a HP Mini 311-1037NR (the product number is VBM262UA #ABA).   My OS is Windows 7 Home Premium. When I start my HP Mini 311, I get the following message: HP battery alert The system has detected the following battery storage capacity is very lo

  • Windows ring you at home?

    Just had a phone call from 'Windows' in the Thames Valley Park, Berkshire, asking me to turn on the computer and enter a few letters in "windows + r" because I had a virus problem. Took the number and said: I would like to remind them. It is a call?

  • Bluescreens ~ 15 min interval... 0X0000009F DRIVER_POWER_STATE_FAILURE

    Hi I'm Philipp, and I hope you can help me with this problem: My system is a Win7 64 bit old for two months on a Toshiba Tecra Notebook z50. During the first-updates Windows appears the first Bluescreen. I tried to solve the problem 0x0000009f DRIVER