[Gambas-user] Size of a result in memory

Christof Thalhofer chrisml at deganius.de
Wed Oct 18 14:33:57 CEST 2017


Hello Tobias,

thank you for your great explanation.

Am 18.10.2017 um 11:05 schrieb Tobias Boege:

> So, you can't get the information you want, but the good news is that this
> information wouldn't have helped you either way. Unless your DBMS is made
> for tiny amounts of data, you shouldn't expect the dynamic memory allocated
> by the Result object to be indicative of the size of the query result.
> A Result object is usually just a small (almost fixed-size) object that is
> associated to a database connection and a query and allows you to fetch or
> navigate through the tuples. The DBMS loads the data on-demand, because
> you would expect that the entirety of a database result would not fit into
> your memory anyway.

But I think your assumption is not right.

Well, the reason for my answer was, that I wrote a Class that inherits
gb.db.Connection and that is able to cache results.

It is for situations, where to fetch the result costs a lot of time and
the result will be needed more than once. This works, I am able to cache
results. To test it I wrote piece of code that starts the connection,
after that fetches the result and the next time the same sql string is
queried, it delivers the cached result:

MTestme.TesteDBCache.44: Init connection for later usage 906
MTestme.TesteDBCache.51: Query1 5000 tuples duration in ms 7397
MTestme.TesteDBCache.61: Cached query 5000 tuples duration in ms 0

You see that in Position 3 duration in ms = 0. The result comes out of
the cache (a collection with the sql query string as key).

Now I have changed the code to do a simple
Connection.Exec(qry):

MTestme.TesteDBCache.44: Init connection for later usage 784
MTestme.TesteDBCache.51: Query1 5000 tuples duration in ms 6228
MTestme.TesteDBCache.61: identical Query duration in ms 5365

Here you see that in position 3 the result is fetched again from the db
and that operation costs an amount of time (5365 ms).

---------

For me the conclusion is, that the result fetches the 5000 tuples once
and then they are inside the result object on the local computer fol
later usage.

As I use these cached results a lot in my programs I would like to
delete old cached results if an upper limit of memory usage is reached.

But therefore I have to know, how "heavy" a result is.


Alles Gute

Christof Thalhofer

-- 
Dies ist keine Signatur

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20171018/e1712c3d/attachment.sig>


More information about the User mailing list