prim matrix query update