question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Running this sql causing high CPU usage and UI freeze

See original GitHub issue

It 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:closed
  • Created 2 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
tohghuacommented, Sep 29, 2021

This library attempts to be “universal” by handling every possible SQL syntax structure of several dialects in a cost of performance impact. I’m not trying to say that the latter is expected, of course such things are inappropriate and should be fixed.

Actually, we’ve updated this library to newer version, can you try running your query against the EA version?

https://dbeaver.io/files/ea/

Thank you! EA version is ok now.

1reaction
GiannisDimitrioucommented, Sep 22, 2021

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found