'fetch in matlab with SELECT using postgreSQL locks table long after completion

code in matlab app:

query = sprintf('select *,st_askml(line) from %s;', table_name);
var = fetch(connection, query);

This completes successfully and I get the data, the app continues running. However if I separately (in this cause within a python script) try to run "drop table if exists" on the same table, it won't work because it is locked;

pg_stat_activity

How should I change my select query in matlab so that it finishes gracefully. (btw the lock is released when I close the app).



Solution 1:[1]

I am open to hearing more details about this but I solved the problem by adding

execute(connection,'COMMIT');

after my select query.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1