Home › Forums › kdb+ › Fast Insert Line into Middle of An In-memory Table › Re: Fast Insert Line into Middle of An In-memory Table
-
Hi Xiaocheng,
A few questions to add more context here;
- Assuming this process is an RDB, is there any particular reason you need to insert rows at a specific index?
- What logic determines the insert index?
For most RBD applications you probably want to avoid sorting until the end of day write down to disk.
If you need to increase performance in querying your RBD process, you could perhaps look at the grouped attribute, which will keep a hash map of the indices for the new rows.
q)tbl:update sym:`g#sym from ([]sym:upper 3?`4;price:3?10f); q)meta tbl c | t f a -----| ----- sym | s g price| f q)tbl sym price -------------- GMEH 7.125845 IKOK 1.392257 CJEK 2.701876 q)tbl:tbl upsert (`ABCD;10f); q)tbl sym price -------------- GMEH 7.125845 IKOK 1.392257 CJEK 2.701876 ABCD 10 q)meta tbl c | t f a -----| ----- sym | s g price| f
Resources:
- Columnar database and query optimization | White Papers | documentation for q and kdb+ – Kdb+ and q documentation (kx.com)
- Set Attribute | Reference | kdb+ and q documentation – Kdb+ and q documentation (kx.com)
- Tables | Q For Mortals | A textbook forkdb+ and the q programming language – Q for Mortals (kx.com)
Hope this helps!
Cheers,
David