I tried both ways and found that they are of similar performance as direct indexing (i.e. t[r[orderID];time]: .z.N;). All of them beats ordinary update statement.
So, unfortunately it looks like there is no way to improve the performance further on updating the entry after calling the ‘first t’
Indeed the problem I am facing is, I am able to pick the first row easily and read the data from the row.
the row returned is a reference.
I was expecting I can modify 1 column value (e.g. time), yet unfortunately once I start to modify the reference it then becomes a copy of the reference.
I could only have to reference the original table by its key/virtual index/where clause/dot operator and modify the value, which this operation is much heavier compared to modifying the returned reference.
If there exists a way that I could modify the value of the reference directly, then it would be perfect.
because such operation is heavy. Say if the table has 100,000 rows and I have to do 100,000 times of update. Each time pick the first row to update a column (assume the first row index changes after a column is modified)
Under such scenario, updating 100K times requires 10 seconds. If I only modified the returned reference(which turns out to be a copy), it takes less than 1 second.
Which triggers my curiosity to look for possibility to make it at 1 second.
It may be of no luck, just share my thoughts here.
If your problem is actually part of the larger problem of updating the column at all or even many of the rows, consider a vector solution: take the whole column, amend what is to be changed, replace the column.
Best
Stephen
Stephen Taylor | Librarian | Kx | +44 7713 400852 | stephen@kx.com
you have not provided the tables schema. have you placed the the `u attribute on the orderID column. this should improve performance overall by changing the search algorithm from linear to hash lookup.
update u#orderID from t
also, instead of updating a copy of the table, you can amend in place: