KX Community

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

Home Forums kdb+ help understanding a function Reply To: help understanding a function

  • rocuinneagain

    Member
    May 30, 2024 at 9:12 am

    Yes with right to left evaluation it is being saved then sorted.

    The reason this may have been done is that sorting in memory will temporarily use extra memory to perform the operation.

    https://code.kx.com/q/ref/asc/#sorting-data-on-disk

    Sorting on disk is very memory efficient as it does not bring the full table in to memory.

    The trade off is it is slower as each column gets written twice.

    q)tab:flip (`$/:.Q.an)!{1000000?10000.0}each .Q.an
    q)\ts `a xasc `:tab/ set tab
    q)
    1824 25168800
    q)\ts `:tab/ set `a xasc tab
    1165 536874192
    q)536874192%25168800
    21.33094 //Sorting in memory uses 21x memory than sorting on disk