KX Community

Find answers, ask questions, and connect with our KX Community around the world.
KX Community Guidelines

Home Forums kdb+ Question about query that stuck the KDB process Re: Question about query that stuck the KDB process

  • Laura

    Administrator
    April 29, 2022 at 12:00 am

    Looks like you have already spotted part of the problem. The / does not denote Divide % but the iteration operator Over. Depending on the values in the size column, you might have inadvertently specified a Converge iteration, and one that might not actually converge. Iterations defined this way run very tight and can be difficult to interrupt.

    The result column you want is perhaps sums[size]%sum[size], or, avoiding computing both sum and sums,
    .[%]1 lastsums size.

     

    q)show size:5?10 6 6 1 8 5 q)sums[size]%sum[size] 0.2307692 0.4615385 0.5 0.8076923 1 q).[%]1 lastsums size 0.2307692 0.4615385 0.5 0.8076923 1

     

    The use above of 1 last is an example of the Zen monks idiom.