Re: How to improve sql query to achieve the better plan

2018-09-30 Thread Pavel Stehule
ne 30. 9. 2018 v 18:49 odesílatel Arup Rakshit napsal: > I just added it as you said, but I am getting same plan. > > > Sort (cost=62842.16..62846.91 rows=1897 width=35) (actual > time=1845.831..1845.950 rows=1229 loops=1) > Sort Key: projects.id > Sort Method: quicksort Memory: 145kB > -

Re: How to improve sql query to achieve the better plan

2018-09-30 Thread Arup Rakshit
I just added it as you said, but I am getting same plan. Sort (cost=62842.16..62846.91 rows=1897 width=35) (actual time=1845.831..1845.950 rows=1229 loops=1) Sort Key: projects.id Sort Method: quicksort Memory: 145kB -> HashAggregate (cost=62710.42..62738.88 rows=1897 width=35) (actual

Re: How to improve sql query to achieve the better plan

2018-09-30 Thread Pavel Stehule
Hi ne 30. 9. 2018 v 18:23 odesílatel Arup Rakshit napsal: > I have the below query which is taking 1873 ms. How can I improve this? > > explain analyze select > sum(coalesce(price_cents, 0)::bigint * coalesce(quantity, 0) * (1 - > coalesce(workitems.discount, 0)/ 100)) as total_budget_cents, > s