Re: Help me in reducing the CPU cost for the high cost query below,as it is hitting production seriously!! - Mailing list pgsql-performance

From Abbas
Subject Re: Help me in reducing the CPU cost for the high cost query below,as it is hitting production seriously!!
Date
Msg-id 1526911926.12183.1@homie.mail.dreamhost.com
Whole thread Raw
In response to Re: Help me in reducing the CPU cost for the high cost query below,as it is hitting production seriously!!  (pavan95 <pavan.postgresdba@gmail.com>)
Responses Re: Help me in reducing the CPU cost for the high cost query below,as it is hitting production seriously!!  (pavan95 <pavan.postgresdba@gmail.com>)
List pgsql-performance
Sure thing. Base 60 or Sexagesimal is the numerical system used for measuring time (1 hour equals to 60 minutes and so on). But this case is even simpler, so without going into much detail about bases, you're mapping between two sets of numbers:

0 -> 0
.15 -> .25
.30 -> .50
.45 -> .75

From working with clocks, we know that 15 minutes is .25 hours, 30 minutes is .5 hours and so on. So you only need to divide the fractional part ( effort_hours - floor(effort_hours) ) by .6 to get what you want.

For example, let's say effort_hours = 1.15; then floor(1.15) is 1; so:

floor(1.15) + ( (1.15 - floor(1.15)) / 0.6 ) = 1 + ( (1.15 - 1) / 0.6 ) = 1 + ( 0.15 / 0.60 ) = 1.25

Hope it helps. Feel free to ask a question if it's still unclear. :)


On Mon, May 21, 2018 at 6:09 PM, pavan95 <pavan.postgresdba@gmail.com> wrote:
Hi Abbas, Thanks for your valuable suggestions. To my surprise I got the same output as what I have executed before. But unfortunately I'm unable to understand the logic of the code, in specific what is base 60 number? The used data type for "effort_hours" column is 'double precision'. Kindly help me in understanding the logic. Thanks in advance. Regards, Pavan -- Sent from: http://www.postgresql-archive.org/PostgreSQL-performance-f2050081.html


pgsql-performance by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: Help me in reducing the CPU cost for the high cost query below,as it is hitting production seriously!!
Next
From: pavan95
Date:
Subject: Re: Help me in reducing the CPU cost for the high cost query below,as it is hitting production seriously!!