Page 1 of 1

Mydac cant handle my database size

Posted: Wed 04 Jun 2008 11:40
by kaffeburk
I have a MySql 5.0 database with 10 000 records and 2.5 gb of size. Its only 2 fields, an integer and a string (the averege string is 80k). There is no index. I have 2 problems with this database:

(1) Database explorer cant open it. It times out when i choose "retrive data". I guess this have to do with the property "fetch all" witch i guess is true (on) . But i cant turn it to false.

(2) When i add records to the database Mydac consumes graduadly more and more memory until my computer runns out of memory. Is there any way to tell mydac, i dont care if u want more memory, you just have to do with what you have and let it take the time it takes.

I have the Build 5.201.15 of mydac and both the connection and query are set to default values, the only thing i changed is "fetch all" that i set to false.

The code that adds records looke like this:

begin
Locker.Acquire; // only one thread @ a time can access this

qry.Insert;

qry.FieldByName('c_id').AsInteger:=id;
qry.FieldByName('c_body').AsString:=body;

qry.Post;

Locker.Release;
end;

dfm:

object Company_connection: TMyConnection
Database = 'swedishcompanys'
Username = 'root'
Password = '******'
Server = 'localhost'
LoginPrompt = False
Left = 88
Top = 48
end

object qry: TMyQuery
SQLInsert.Strings = (
'INSERT INTO companys'
' (c_id, c_body)'
'VALUES'
' (:c_id, :c_body)')
SQLDelete.Strings = (
'DELETE FROM companys'
'WHERE'
' c_id = :Old_c_id')
SQLUpdate.Strings = (
'UPDATE companys'
'SET'
' c_id = :c_id, c_body = :c_body'
'WHERE'
' c_id = :Old_c_id')
SQLRefresh.Strings = (
'SELECT companys.c_id, companys.c_body FROM companys'
'WHERE'
' companys.c_id = :c_id')
Connection = Company_connection
SQL.Strings = (
'SELECT'
' swedishcompanys.companys.c_id,'
' swedishcompanys.companys.c_body'
'FROM'
' swedishcompanys.companys')
FetchAll = False
Left = 144
Top = 48
end

Posted: Thu 05 Jun 2008 11:13
by Antaeus
The dataset size is really big. To avoid the problem with out of memory, you should restrict requested records count by some conditions in the WHERE clause.
If you need to handle all records one by one in your application (caching is not required), set the Unidirectional property of your query to True.

Posted: Thu 05 Jun 2008 15:33
by kaffeburk
When i change unidirectional to True i get error:

"cant modify a read only dataset"

I only need to add rows (yet)

The documanation of unidirectional does not mention that the dataset becomes "read only".

the readonly property is set to False, am i doing something wrong or bug in mydac?

Posted: Fri 06 Jun 2008 07:54
by jkuiper_them
kaffeburk wrote:When i change unidirectional to True i get error:
"cant modify a read only dataset"
I only need to add rows (yet)
The documanation of unidirectional does not mention that the dataset becomes "read only".
the readonly property is set to False, am i doing something wrong or bug in mydac?
Unidirectional tables requires a provider and a clientdataset.

Posted: Fri 06 Jun 2008 08:18
by kaffeburk
jkuiper_them wrote: Unidirectional tables requires a provider and a clientdataset.
Where is this documented (where can i read more of this). I cant find it.

Posted: Fri 06 Jun 2008 08:27
by Antaeus
For loading many records into the server it is better to use the TMyLoader component or TMyCommand with parameterized INSERT query. These ways are faster and consumes less memory in comparison with TMyQuery.Insert/Post.

Posted: Fri 06 Jun 2008 09:18
by kaffeburk
Antaeus wrote:For loading many records into the server it is better to use the TMyLoader component or TMyCommand with parameterized INSERT query. These ways are faster and consumes less memory in comparison with TMyQuery.Insert/Post.
Yes, im on that track now, thanx!