KX Community

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

Home Forums KX Academy Function of syntax ` Re: Function of syntax `

  • pcarroll

    Member
    January 21, 2022 at 12:00 am

    Also, this just brings up good questions about symbols versus strings & when and why we use them.
    Many languages including q intern strings so that only one copy of any distinct value is stored. Any other references to the same string are stored as just that, references.
    This helps with memory management, and improves performance on equality comparison i.e.

    // assuming col1 is symbol column 
    
    q)select from tab where col1 in `a`b

    Storing the same string e.g. “New York Stock Exchange” repeatedly in memory would require a greater amount of memory than its symbol counterpart.

    Because q typically stores the string pool entirely in memory (that’s what your sym file is in a typical kdb+ database) consideration should be given as to what columns are symbol and which are string.

    If the string list contains many short repeated values this may be a good candidate for casting to a symbol