VCursor_Destructor

Ivan Smahin ivan_smahin at paradigmasoft.com
Tue Dec 16 03:52:50 CST 2014


On Dec 16, 2014, at 11:09, Mark Schonewille <m.schonewille at economy-x-talk.com> wrote:

> Hi Ivan,
> 
> The first two are kind of evident, although I tend to believe that these become important as a database gets more complicated.
> 
> The third point is interesting. Every time I do a query with a cursor, I create a new cursor and store this in a variable. Perhaps I might have a dozen of small queries with a cursor for each. Does deleting these cursors really enhance code accuracy? How? Would I have less bugs in my code because I always close the cursors when I don't need them any more?
> 

Cursor is a kind of resource, sort of opaque one. You can not be sure that keeping resource alive (more than you need) is not affecting other components (your app, another clients in case of vServer programming, memory/CPU .... consuming). 

One more point. Having a lot of code you can easily find yourself in "record is locking by another cursor" situation. Yes, you know that it's your cursor (one of) but which one? and, is it abandoned or really used one?
Moreover, what if your app is running a long time and there are thousands cursors (not really used) because each iteration produces new cursor?

How deleting cursors enhances code accuracy?
Simple - you always know when your cursor born and when your cursor dies. So you can improve, refactoring, ... your app without afraid of something goes wrong after it.


So "free resource as soon as possible" is a good approach, always. 


-- 
Best regards,
Ivan Smahin
Senior Software Engineer
Paradigma Software, Inc
Valentina - The Ultra-Fast Database
http://www.valentina-db.com



More information about the Valentina mailing list