From: Abbas <abbas@rechat.com>
To: pavan95 <pavan.postgresdba@gmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Help me in reducing the CPU cost for the high cost query below, as it is hitting production seriously!!
Date: Mon, 21 May 2018 18:12:06 +0400
Message-ID: <1526911926.12183.1@homie.mail.dreamhost.com> (raw)
In-Reply-To: <1526909995520-0.post@n3.nabble.com>
References: <1526883356469-0.post@n3.nabble.com>
<1526889830358-0.post@n3.nabble.com>
<1526901200599-0.post@n3.nabble.com>
<1526902087.12183.0@homie.mail.dreamhost.com>
<1526909995520-0.post@n3.nabble.com>
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
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: abbas@rechat.com, pavan.postgresdba@gmail.com
Subject: Re: Help me in reducing the CPU cost for the high cost query below, as it is hitting production seriously!!
In-Reply-To: <1526911926.12183.1@homie.mail.dreamhost.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox