#1 2020-11-08 18:03:52

edwinsn
Member
Registered: 2010-07-02
Posts: 1,215

Need general advises for a lot of small databases & cached records.

I have a project might be a little different than the usual use cases, and I want some general advises as to reducing **memory use** and **improving performance**.

- The program will open a folder which might contain a lot of files and subfolders.
- In each subfolder there is a sqlite db and its corresponding TSQLRestServerDB be created.
- for each file the program will create an object of a TSQLRecord-decendent for it.

The problem is that for folders with many subfolders, the RAM consumption go up.

Any options to reduce the memory consumption for TSQLRestServerDB  and TSQLRecord objects?

Thanks!


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#2 2020-11-08 20:12:58

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,231
Website

Re: Need general advises for a lot of small databases & cached records.

What takes memory is the SQLite3 internal cache.

You can
1. Reduce the cache size assigned with each TSQLRestServerDB
2. Maintain a pool of TSQLRestServerDB, and keep only e.g. the last 20 instances in memory

I usually used a combination of the two, on production, in such use cases.

Offline

#3 2020-11-09 08:54:46

edwinsn
Member
Registered: 2010-07-02
Posts: 1,215

Re: Need general advises for a lot of small databases & cached records.

@ab,

Thanks! Very helpful!

I also noticed TSQLDataBase.SetUseCache  will create a TSynCache object:

TSynCache.Create(16384*1024,true)

which is a 16-Mb framework-level cache.

Unfortunately, the size of the TSynCache size is hard-coded. Any chance to make it configure-able? wink


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#4 2020-11-09 09:23:17

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,231
Website

Re: Need general advises for a lot of small databases & cached records.

Offline

#5 2020-11-09 10:38:25

edwinsn
Member
Registered: 2010-07-02
Posts: 1,215

Re: Need general advises for a lot of small databases & cached records.

Great! Thanks! Excellent support of an open source project, as always!


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

Board footer

Powered by FluxBB