Hello!
1st : sorry for my bad English...
Please give me some hint about this problem:
Tables:
create table DEF_OBJECT
(
ID INTEGER not null,
OBJECT_TYPE_ID INTEGER not null,
LAST_DETAIL_ID INTEGER not null,
INACTIVE TINYINT UNSIGNED not null default 0,
INTEGRATED TINYINT UNSIGNED not null default 0,
USER_KEY VARCHAR(255),
primary key (ID)
);
create table DETAIL_OBJECT
(
ID INTEGER not null,
OBJECT_ID INTEGER not null,
PREV_DETAIL_ID INTEGER not null,
D_DATE DATE not null,
D_TIME TIME not null,
D_DATETIME DATETIME not null,
DESCRIPTION TEXT,
primary key (ID)
);
create table DEF_OBJECT_PROPERTY
(
ID INTEGER not null,
DETAIL_ID INTEGER not null,
PROPERTY_ID INTEGER not null,
VALUE_INT INTEGER,
VALUE_STR TEXT,
VALUE_DATE DATETIME,
VALUE_EXT DOUBLE,
primary key (ID)
);
Query:
SELECT *,op.ID as OPID,h.ID as OBJID FROM DEF_OBJECT h INNER JOIN DETAIL_OBJECT d ON h.LAST_DETAIL_ID=d.ID INNER JOIN DEF_OBJECT_PROPERTY op ON op.DETAIL_ID=d.ID WHERE h.OBJECT_TYPE_ID=:pObjectTypeID ORDER BY h.ID,op.ID;
Record count in database:
DEF_OBJECT : 1100
DETAIL_OBJECT : 1100
DEF_OBJECT_PROPERTY : 15400
The Delphi Code:
sql.Open;
While not sql.Eof Do
Begin
o := CDBO_Object.Create;
o.iOuterPropertyCache := True;
o.iPropertyCache := iPropertyCache;
o.LoadHeaderFromSQL(sql);
o.LoadObjectPropertiesFromSQL(sql);
iObjects.Add(o);
End;
sql.Free;
Run times:
mysql console : very fast
delphi code : >10 seconds!!! (my .exe's CPU=88%, and mysql's CPU=10%)