Mydac cant handle my database size

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
kaffeburk
Posts: 214
Joined: Mon 29 Jan 2007 08:03

Mydac cant handle my database size

Post by kaffeburk » Wed 04 Jun 2008 11:40

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

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Thu 05 Jun 2008 11:13

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.

kaffeburk
Posts: 214
Joined: Mon 29 Jan 2007 08:03

Post by kaffeburk » Thu 05 Jun 2008 15:33

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?

jkuiper_them
Posts: 28
Joined: Thu 20 Dec 2007 14:48

Post by jkuiper_them » Fri 06 Jun 2008 07:54

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.

kaffeburk
Posts: 214
Joined: Mon 29 Jan 2007 08:03

Post by kaffeburk » Fri 06 Jun 2008 08:18

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.

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Fri 06 Jun 2008 08:27

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.

kaffeburk
Posts: 214
Joined: Mon 29 Jan 2007 08:03

Post by kaffeburk » Fri 06 Jun 2008 09:18

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!

Post Reply