#1 2010-07-12 08:23:28

longge007
Member
Registered: 2010-06-22
Posts: 107

The httpServer can work as Memorydb and diskDB?

i don't know whether or not the Httpserver can  work as  not only a Memorydb not but also holddiskDb?
there are some good uses.
1)Realtime data only process in Memory Db
2)historytime data saved in holddiskDB.

Sir, do you have some good ideas?

Offline

#2 2010-07-12 08:41:38

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

Re: The httpServer can work as Memorydb and diskDB?

I don't think why you shouldn't use a regular database, and save its content to the disk.

But there is a possibility to store some tables only in memory, not in the main SQLite3 database file. I don't know if it's what you are looking for.

You just have to define a TSQLRecord child, then create a DB server (e.g. a TSQLRestServerDB instance), and call StaticDataCreate() method before the CreateMissingTables() method.

type
  TSQLStaticData = class(TSQLRecord)
   ... define here a table, with properties to be kept in memory
  end;

procedure DatabaseCreate;
begin
  DB := TSQLRestServerDB.Create(DBModel,'filename.db3');
  DB.StaticDataCreate(TSQLStaticData); // the TSQLStaticData table will be in memory
  DB.CreateMissingTables;
  HttpServer := TSQLite3HttpServer.Create('888',DB);
end;

When you quit the server application, all data contained in the TSQLStaticData table will be lost. But it could be accessible from any client application, like any other table.

Just a note about static tables: they just handle basic SQL statements, like "SELECT * FROM StaticData WHERE ID=23", not full qualified cross-table statements or such. But they are MUCH faster than the standard SQLite3 tables.

You can write the static tables content on disk, as JSON, if you specify a filename to the StaticDataCreate() method... but it's not perhaps what you need: in this case, you should better use a regular SQlite3 table.

Offline

#3 2010-07-12 08:53:45

longge007
Member
Registered: 2010-06-22
Posts: 107

Re: The httpServer can work as Memorydb and diskDB?

ok,thanks a lot,
because my realtime table have about 20000 Records.i can use Update()* the static table , and In client use

INSERT INTO historytable select * from static table 

at first.I worry about it will occupy pc resource, perhaps i should test httpserver's performace and ask question
smile

Last edited by longge007 (2010-07-12 09:12:41)

Offline

#4 2010-07-12 08:59:57

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

Re: The httpServer can work as Memorydb and diskDB?

if these 20000 rows of data is not meant to be saved on disk, it could be a solution to use StaticDataCreate. It depends on the data stored in it. About performances, handling 20000 rows is no problem for a static in memory engine.

You just have to guess how much memory it will use. If the data just contains text or numbers, I think your RAM will be big enough to handle it. Just guess the average size of every record, then multiply by 20000...

Offline

#5 2010-07-12 09:17:27

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

Re: The httpServer can work as Memorydb and diskDB?

1. The insert command won't work: it will say to you an unknown table error, because statictable is not known by SQLite3 (it's internal to the framework)...

2. I'm sure it's not worth using such a memory copy then update the file on disk. SQlite3 is fast enough using regular access.

Offline

#6 2010-07-12 09:22:27

longge007
Member
Registered: 2010-06-22
Posts: 107

Re: The httpServer can work as Memorydb and diskDB?

ab wrote:

1. The insert command won't work: it will say to you an unknown table error, because statictable is not known by SQLite3 (it's internal to the framework)...

yeah, you are right, the Insert command don't work.
ok,i think i still use normal access to handle it.

thanks a lot

Offline

Board footer

Powered by FluxBB