KX Community

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

Home Forums kdb+ What is the role played by key columns in a keyed table [ query join/performance ] ? Re: What is the role played by key columns in a keyed table [ query join/performance ] ?

  • darrenwsun

    Member
    May 24, 2022 at 12:00 am

    With qsql, the full column is searched before the result is presented. With key lookup, the search stops when it finds the first match. This is where the performance gain from key lookup comes from.

    > The keys are basically nodes on a BST ( binary search tree ) which should look up in O(log(n)) time given n is size of the table

    This isn’t true. KDB’s keyed table, or more generally a plain dictionary, does not use hashing techniques like Java’s HashMap. Lookup is done by searching through the table/list linearly. If one wishes less time for the lookup, grouped (conceptually the same as index) or parted (conceptually a space-optimized index that assumes data are sorted) attributes help.