FreFormQuery/TableQuery

Hi, We are using the TableQuery to store the data in data base and its taking long time to save the same. Below is the code snippet we are using and it’s loading the entire table data at line 2 (which is taking time) and filtering the required row by addContainerFilter later at line 3.

TableQuery query = new TableQuery( table, Database.getSolutionDatabase().getConnectionPool())
SQLContainer sqlContainer = new SQLContainer( query );
sqlContainer.addContainerFilter( new Compare.Equal( primaryKeyColID, solutionId ) );
Is there any alternate way to load only the required row data by passing the primary key , instead of loading the entire table data and adding the filter after that.

Is there any alternate to TableQuery with write option ? We have seen the FreeFormQuery, but it’s read-only and we can’t commit the changes to DataBase.

Your help is highly appreciated.