Running this sql causing high CPU usage and UI freeze
See original GitHub issueIt is found in 21.1.5, while 21.1.3 is ok.
I run this sql in a mysql server:
select t.id,0 rn,case when t.is_spec=1 then '+' when t.has_child = 1 then '→' else '' end rn2,t.enabled,t.code,t.name,t.spec,pu.barcode,t.model,a.name brand,_1.qty,pun.name unit,_1.amtd/nullif(_1.qty,0) costd,_1.amtd,_1.qty_tui,_1.qty_tui*100/nullif(_1.qty+ifnull(_1.qty_tui,0),0) tr,_1.out_amt/nullif(_1.qty,0) out_cost,_1.out_amt,_1.amtd-ifnull(_1.profit,0)-ifnull(_1.out_amt,0) other_amt,ifnull(_1.profit,0)+ifnull(_1.out_amt,0) yhh_amt,round(100*_1.profit/nullif(_1.amtd,0),2) p_rate,_1.profit,0. `qty%`,0. `amt%`,0. `profit%`,t.comment
from product t force index (product_site_id_IDX,product_un,product_u_code)
left join product_unit pu on pu.product_id=t.id and pu.is_base=1
left join lookup a on a.id=t.brand_id
left join (select sum(t.qty*(case when b.bill_type in ('RUKU2','RUKUG2','CHUKU2','ZENG_SONG') then -1 else 1 end)) qty,sum(t.amount_disc*(case when b.bill_type in ('RUKU2','RUKUG2','CHUKU2','ZENG_SONG') then -1 else 1 end)) amtd,sum(case when b.bill_type='CHUKU2' then t.qty end) qty_tui,sum((if(b.bill_type = 'LEND3' or b.bill_type = 'CHUKU' and b.in_warehouse_id is null and b.out_warehouse_id is null, t.ship_amount, -sh.amount))) out_amt,sum(((case when b.bill_type in ('RUKU2','RUKUG2','CHUKU2','ZENG_SONG') then -1 else 1 end) * (t.amount_disc - ifnull(t.ship_amount, 0) - (ifnull(t.ret_amount, 0))) + ifnull(sh.amount,0) - ((case when b.bill_type in ('RUKU2','RUKUG2','CHUKU2','ZENG_SONG') then -1 else 1 end) * ifnull(if(b.bill_type in ('CHUKU','CHUKU2'),t.change_amt,if(t.main_pb = 1,b.change_amount,0)),0)))) profit,left(p.paths, 4) root
from product_bill t ignore index (product_bill_product_fk)
left join product p on p.id=t.product_id
join bill_index b use index (index_5,bill_index_site_id_idx) on b.id=t.bill_index_id
left join stock_hist sh on sh.product_bill_id=t.id
where b.site_id in (4362) and b.hide_lc = 0 and b.state in (3,4,5) and b.bill_type in ('CHUKU','CHUKU3','CHUKU2','CHUKU_CHG','WEI_TUOJ') and (b.bill_date >= '2021-08-26 00:00:00' and b.bill_date < '2021-08-29 00:00:00')
group by left(p.paths, 4)) _1 on _1.root=t.paths
left join lookup pun on pun.id=pu.unit_id
where _1.qty is not null and t.site_id = 4362 and t.paths like '____' and t.enabled = 1
order by t.id ASC limit 0,101
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (5 by maintainers)
Top Results From Across the Web
Troubleshoot high-CPU-usage issues in SQL Server
This article provides a procedure to help you fix high-CPU-usage issues on a server that is running SQL Server.
Read more >AWSPerformMutationOperation causes high CPU usage and ...
AWSPerformMutationOperation uses an unnecessary amount of CPU, causing the UI to freeze and sometimes crashes the program if too many mutations ...
Read more >SQL Server freezes (because of application), need logging
The DAC uses distinct, pre-reserved resources (memory, CPU, IO ports etc) exactly so it can be used even when the server is 'frozen'....
Read more >UI freeze when editing SQL string : DBE-10408 - YouTrack
What steps will sometimes reproduce the problem? Load the attached file into an editor. Ctrl+G 20:30, into the SQL statement. What happens? The...
Read more >SQL Developer 17.2.0.188.1159 freeze and high CPU usage ...
When I close explain plan tab, SQL Developer is again usable. I'm running Ubuntu 17.04. I tried Unity and Gnome-shell with no difference....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you! EA version is ok now.
To be honest I find it strange that the project relied to a 3rd party library that is not stable. Essentially whoever wants to use DBeaver for anything else than simple ‘select’ queries must stay at a version <=21.1.3