postgresql – how to sum times in EXPLAIN for Postgres parallel query

I’m having trouble understanding this EXPLAIN on Postgres 12.3:


This is a 22GB table with 30 million rows, on a server with 16GB memory. The query counts 7 matching rows.

I interpret the output as saying 164 seconds was spent on I/O, yet the whole query only took 65 seconds. I thought it might be double counting some parallel workers, but when I add VERBOSE, it doesn’t seem to add up either.

It looks like it’s saying each of 2 workers spent ~55 seconds reading. If that sums to 110 seconds, how do I get to 164 seconds of I/O? (Since this query takes ~10 seconds when pages are cached, I’m guessing the actual time reading isn’t too far from 50 seconds here, FWIW)

I’m also confused how the Parallel Seq Scan seems to take 32 seconds, but then there’s still another 30+ seconds left to get the final result. I would think that because of the 7 rows it finds, there’s really almost no work to do besides the scan. Am I reading this section wrong?

                                                                       QUERY PLAN
 Finalize Aggregate  (cost=3092377.14..3092377.15 rows=1 width=8) (actual time=65028.818..65028.818 rows=1 loops=1)
   Output: count(1)
   Buffers: shared hit=75086 read=2858433 dirtied=1
   I/O Timings: read=164712.060
   ->  Gather  (cost=3092376.92..3092377.13 rows=2 width=8) (actual time=65028.732..65030.093 rows=3 loops=1)
         Output: (PARTIAL count(1))
         Workers Planned: 2
         Workers Launched: 2
         Buffers: shared hit=75086 read=2858433 dirtied=1
         I/O Timings: read=164712.060
         ->  Partial Aggregate  (cost=3091376.92..3091376.93 rows=1 width=8) (actual time=65026.990..65026.990 rows=1 loops=3)
               Output: PARTIAL count(1)
               Buffers: shared hit=75086 read=2858433 dirtied=1
               I/O Timings: read=164712.060
               Worker 0: actual time=65026.164..65026.164 rows=1 loops=1
                 Buffers: shared hit=25002 read=952587
                 I/O Timings: read=54906.994
               Worker 1: actual time=65026.264..65026.264 rows=1 loops=1
                 Buffers: shared hit=25062 read=954370 dirtied=1
                 I/O Timings: read=54889.244
               ->  Parallel Seq Scan on public.ui_events_v2  (cost=0.00..3091374.68 rows=896 width=0) (actual time=31764.552..65026.980 rows=2 loops=3)
                     Filter: ( ~ 'foo'::text)
                     Rows Removed by Filter: 10112272
                     Buffers: shared hit=75086 read=2858433 dirtied=1
                     I/O Timings: read=164712.060
                     Worker 0: actual time=16869.988..65026.156 rows=2 loops=1
                       Buffers: shared hit=25002 read=952587
                       I/O Timings: read=54906.994
                     Worker 1: actual time=64091.539..65026.258 rows=1 loops=1
                       Buffers: shared hit=25062 read=954370 dirtied=1
                       I/O Timings: read=54889.244
 Planning Time: 0.333 ms
 Execution Time: 65030.133 ms

nt.number theory – Explicit bound for sum of Kloosterman sums

What are the best fully explicit upper bounds one can give for the sum
$$leftlvert sum_{n=N}^{infty} frac{S(a,b;n)}{n} ,I_1!left(frac{4 pi sqrt{|ab|}}{n}right) rightlvert$$
where $S(a,b;n) = sum_{gcd(k,n)=1} e^{2 pi i (ak+bk’)/n}$ is the ordinary Kloosterman sum?

As a generalization one may consider any sufficiently regular function $f(C/n)$ instead of the Bessel function.

A trivial bound follows from using Weil’s bound $|S(a,b;n)| le tau(n) sqrt{gcd(a,b,n)} sqrt{n}$, plugging in an explicit bound for $tau(n)$, and summing the series (see for example Brisebarre and Philibert), but this is quite pessimistic.

The problem of bounding such sums is discussed in Sarnak and Tsimerman, On Linnik and Selberg’s conjecture about sums of Kloosterman sums. As far as I can tell, there are no published bounds (other than the trivial one) with fully explicit constants.

wp query – PHP SUM using post Custom Field

I am trying to update a numeric custom field by ‘adding’ a number from a front-end form.
The script I wrote is not adding the existing number, but just updating to the new number entered in the form.

I haven’t been able to make it work but I think there needs to be some sort of conversion for the get_post_meta function for the script to understand it as a number.

The basic script I wrote is:

if(isset($_POST('Add_Work_Task')) == '1'){
    $Current_Buried_Hours =get_post_meta( $Parent_Work, 'Work_Buried_Hours',true);

    $Total_Buried_Hours= $Current_Buried_Hours + $Work_Required_Hours;

    $Buried_Required_Hours= array('Work_Buried_Hours' => $Total_Buried_Hours);
                                        'ID'        => $Parent_Work,
                                        'meta_input'=> $Buried_Required_Hours,

I also tried

$Total_Buried_Hours= (float)$Current_Buried_Hours + (float)$Work_Required_Hours;

$Total_Buried_Hours= floatval($Current_Buried_Hours) + floatval($Work_Required_Hours);

$Total_Buried_Hours= $Current_Buried_Hours += $Work_Required_Hours;

$Total_Buried_Hours= print_r($Current_Buried_Hours) + $Work_Required_Hours; this one adds 1 only.


$Current_Buried_Hours =implode(".",get_post_meta( $Parent_Work, 'Work_Buried_Hours',true));

To narrow it down I know for a fact the problem is with the get_post_meta function, I have tested adding the $_POST twice and it worked like the following:

$Total_Buried_Hours= $Work_Required_Hours + $Work_Required_Hours;

sequences and series – Lower bound for sum of reciprocals of positive real numbers

I am reading an article where the author seems to use a known relationship between the sum of a finite sequence of real positive numbers $a_1 +a_2 +… +a_n = m$ and the sum of their reciprocals. In particular, I suspect that
sum_{i=1}^n frac{1}{a_i} geq frac{n^2}{m}

with equality when $a_i = frac{m}{n} forall i$. Are there any references or known theorems where this inequality is proven?

This interesting answer provides a different lower bound. However, I am doing some experimental evaluations where the bound is working perfectly (varying $n$ and using $10^7$ uniformly distributed random numbers).

javascript – Best combination of a sum between two parameters in an array of objects

I am trying to build a simple algorithm to achieve the best combination of values based on two params in an array of objects.

The whole code is available here

First I have an array holding objects. The items which will be analyzed and packed into volumes together. All of the values are in percentages.

const nonStackableItems = (
      id: 0,
      m2: 15,
      m3: 11,
      weight: 20
      id: 1,
      m2: 25,
      m3: 12,
      weight: 42
      id: 2,
      m2: 50,
      m3: 13,
      weight: 40
      id: 3,
      m2: 65,
      m3: 14,
      weight: 25

The idea is to combine these objects into packages, respecting the maximum of 100% for each value (except for m3 in this case, as all the packages should have enough height in this first analysis).

The approach that I gave is just not good enough, as I am sorting this array by m2 then by weight, call the function and then compare the length of both, and then choose the result that creates less volumes.

This is the piece of code that does the calculations:

function nSVolHelper(arr, vol, param1, param2) {
    let newVol = {
      id: vol.length,
      m2: 0,
      m3: 0,
      weight: 0
    for (let i = 0; i < arr.length; i++) {
      const validation =
        newVol(param1) + arr(i)(param1) < 100 &&
        newVol.m2 + arr(i)(param2) < 100;
      if (validation) {
        newVol.m2 += arr(i).m2;
        newVol.m3 += arr(i).m3;
        newVol.weight += arr(i).weight;
      if (!validation) {
        return nSVolHelper(arr.slice(i), (...vol, newVol), param1, param2);
    return vol;

  function nSVol(arr, param1, param2) {
    return nSVolHelper(arr, (), param1, param2);

I would like to find a way of doing this without taking as a base the order of the array, to get the finest calculation without running unnecessary code, and I get the feeling that this approach of mine is just not reliable as well.

As an example, for better understanding:

If I pass the array sorted by weight I get a create 2 volumes.

      nonStackableItems.sort((a, b) => a.weight - b.weight),

If I pass this same array sorted by m2 I get 3 volumes.

      nonStackableItems.sort((a, b) => a.m2 - b.m2),

This was the best approach that I could find, but I feel that there could be another way of thinking of this.

how can I sum 2 calculated fields when some of them are blank

I am trying to sum 2 calculated fields in excel, but in the second one, there are some values that show as blanks, and the total does not show any value for the rows in which there are blanks. I NEED HELPP!!!!!
enter image description here

Write a java program to find the sum of the following series: S=1+1/4!-2/9!+3/16!-4/25!…n terms [closed]

Sum of the series program
Conditions-PLs solve this program with scanner class
I have been trying to solve this program from many days but I am no able to, please help

unity – Iterate over a loop to calculate a sum, or update a sum variable as items are added and deleted from a list?

I thought I ran into this concept at one point but can’t figure out how to find an answer for it.

Is it better to iterate over a list of ints to calculate a running sum each frame, or is it better to create a variable to hold the sum and to increase or decrease it as numbers are added to the list?

The only downside I see for keeping a sum variable around is that you have to make sure you really update it correctly in all niche cases that might appear. Or ensure that items are removed from the list correctly, say, on death.

Sum of a series with

I am trying to compute the sum of the following series:
$$sum_{n=1}^infty 3^{n-1}sin ^3{frac{a}{3^n}}$$
The series is clearly convergent by the ratio test, as well as by comparison with $(frac{a}{3^n})^3$. If I take the derivative with respect to $a$, I am eventually left with $cos(frac{a}{3^n})-cos^3(frac{a}{3^n})$, which doesn’t seem very helpful, plus I’m not sure it’s okay to take the derivative. Multiplying by sine functions to try to get a telescopical sum didn’t lead me anywhere. Any ideas will be appreciated. Thanks!

Binomial Coefficients sum

Any idea on whether or not $$sum_{i = 0}^b(-1)^ibinom{b}{i}binom{a+b-i-1}{a-i}$$
has a closed formula on $a$ and $b$ (and on what it is, in case it does)?

It is supposed that $b le a$.