I'm having a problem with the database toolbox. So here is my situation:
I open a connection to the database. This connection remains active till I close the figure/program. For data import I have to use the database toolbox (not the visual query builder), because the users don't know how to handle SQL queries.
The data I'm fetching from the database is around one million rows, two columns per query. When I first execute the cursor exec statement, it takes about half a second. Here is the code:
curs=exec(conn,['Select EKG,unique_unix_timestamp from DATABASENAME where subjectId=XX order by unique_unix_timestamp asc`
The execution time should be fast as unique_unix_timestamp is a key and has an index on it. For fetching data, I use rowlimit until no more data is available:
curs = fetch(curs, rowLimit);
data = [data;curs.Data];
After that, I close the cursor until the user wants to load data from the next subject. My problem is: Every time I execute the cursor statement (not the fetch), it takes longer (from two s in the beginning to 5 minutes after two-three queries). Do cursors remain open even after closing them? Is there a way to view all open cursors? How comes the execution time is so slow (in contrast to actually fetching the data)? I have tried to close the cursor, close cursor and clear the cursor, manually execute garbage collection, nothing helps. I don't know what else to do and hope you can give me any hints. Here is what I do to clear the data.
When tracking the java heap space, it goes from 100mb to 300mb after each cursor execution and falls down to 100mb after garbage collection. The only thing that changes is how steep the java heap space increases..
I hope you guys understand my situation and can help me.
update: I have added an image from my jconsole tracking. Here we go: