Autor Beitrag
Boldar
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1555
Erhaltene Danke: 70

Win7 Enterprise 64bit, Win XP SP2
Turbo Delphi
BeitragVerfasst: Di 15.07.14 11:32 
Hallo,
ich benutze gerade testweise dafür eine MySQL-Datenbank. Diese läuft remote, und ich benutze die dll der C-api mit der mysql.pas.
Ich muss nun viele Daten einfügen, daher fasse ich immer mehrere inserts zu einem statement zusammen. Das sieht dann so aus:
ausblenden Delphi-Quelltext
1:
2:
  mysql_real_query(_myCon, PAnsiChar(query), Length(query));
  while ( mysql_more_results(_myCon)) do mysql_next_result(_myCon);


Die Schleife brauche ich, weil sonst ein
ausblenden Quelltext
1:
Commands out of sync; you can't run this command now					

kommt. Leider geht in der schleife aber auch >90% der zeit verloren. Ich brauche ja eigentlich kein Ergebnis (das query ist ein insert), gibt es da keine bessere Lösung?
Beispielquery:
ausblenden Quelltext
1:
 INSERT INTO `messdaten`.`values` (`idx`, `value`, `mset`, `parameter`) VALUES (NULL, 32176,0, NULL); SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`coordinates` (`index`, `name`, `correspondingvalue`, `coordinate`) VALUES (NULL, 'x', @mvalue, 0),(NULL, 'y', @mvalue, 0),(NULL, 'z', @mvalue, 28500),(NULL, 'p1', @mvalue, 0),(NULL, 'p2', @mvalue, 0),(NULL, 'px', @mvalue, 25600),(NULL, 'py', @mvalue, 25600),(NULL, 'pz', @mvalue, 0);SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`values` (`idx`, `value`, `mset`, `parameter`) VALUES (NULL, 835,0, NULL); SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`coordinates` (`index`, `name`, `correspondingvalue`, `coordinate`) VALUES (NULL, 'x', @mvalue, 100),(NULL, 'y', @mvalue, 0),(NULL, 'z', @mvalue, 28500),(NULL, 'p1', @mvalue, 0),(NULL, 'p2', @mvalue, 0),(NULL, 'px', @mvalue, 25600),(NULL, 'py', @mvalue, 25600),(NULL, 'pz', @mvalue, 0);SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`values` (`idx`, `value`, `mset`, `parameter`) VALUES (NULL, 903,0, NULL); SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`coordinates` (`index`, `name`, `correspondingvalue`, `coordinate`) VALUES (NULL, 'x', @mvalue, 200),(NULL, 'y', @mvalue, 0),(NULL, 'z', @mvalue, 28500),(NULL, 'p1', @mvalue, 0),(NULL, 'p2', @mvalue, 0),(NULL, 'px', @mvalue, 25600),(NULL, 'py', @mvalue, 25600),(NULL, 'pz', @mvalue, 0);SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`values` (`idx`, `value`, `mset`, `parameter`) VALUES (NULL, 1195,0, NULL); SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`coordinates` (`index`, `name`, `correspondingvalue`, `coordinate`) VALUES (NULL, 'x', @mvalue, 300),(NULL, 'y', @mvalue, 0),(NULL, 'z', @mvalue, 28500),(NULL, 'p1', @mvalue, 0),(NULL, 'p2', @mvalue, 0),(NULL, 'px', @mvalue, 25600),(NULL, 'py', @mvalue, 25600),(NULL, 'pz', @mvalue, 0);SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`values` (`idx`, `value`, `mset`, `parameter`) VALUES (NULL, 1251,0, NULL); SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`coordinates` (`index`, `name`, `correspondingvalue`, `coordinate`) VALUES (NULL, 'x', @mvalue, 400),(NULL, 'y', @mvalue, 0),(NULL, 'z', @mvalue, 28500),(NULL, 'p1', @mvalue, 0),(NULL, 'p2', @mvalue, 0),(NULL, 'px', @mvalue, 25600),(NULL, 'py', @mvalue, 25600),(NULL, 'pz', @mvalue, 0);SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`values` (`idx`, `value`, `mset`, `parameter`) VALUES (NULL, 1271,0, NULL); SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`coordinates` (`index`, `name`, `correspondingvalue`, `coordinate`) VALUES (NULL, 'x', @mvalue, 500),(NULL, 'y', @mvalue, 0),(NULL, 'z', @mvalue, 28500),(NULL, 'p1', @mvalue, 0),(NULL, 'p2', @mvalue, 0),(NULL, 'px', @mvalue, 25600),(NULL, 'py', @mvalue, 25600),(NULL, 'pz', @mvalue, 0);SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`values` (`idx`, `value`, `mset`, `parameter`) VALUES (NULL, 1223,0, NULL); SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`coordinates` (`index`, `name`, `correspondingvalue`, `coordinate`) VALUES (NULL, 'x', @mvalue, 600),(NULL, 'y', @mvalue, 0),(NULL, 'z', @mvalue, 28500),(NULL, 'p1', @mvalue, 0),(NULL, 'p2', @mvalue, 0),(NULL, 'px', @mvalue, 25600),(NULL, 'py', @mvalue, 25600),(NULL, 'pz', @mvalue, 0);SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`values` (`idx`, `value`, `mset`, `parameter`) VALUES (NULL, 1428,0, NULL); SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`coordinates` (`index`, `name`, `correspondingvalue`, `coordinate`) VALUES (NULL, 'x', @mvalue, 700),(NULL, 'y', @mvalue, 0),(NULL, 'z', @mvalue, 28500),(NULL, 'p1', @mvalue, 0),(NULL, 'p2', @mvalue, 0),(NULL, 'px', @mvalue, 25600),(NULL, 'py', @mvalue, 25600),(NULL, 'pz', @mvalue, 0);SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`values` (`idx`, `value`, `mset`, `parameter`) VALUES (NULL, 1656,0, NULL); SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`coordinates` (`index`, `name`, `correspondingvalue`, `coordinate`) VALUES (NULL, 'x', @mvalue, 800),(NULL, 'y', @mvalue, 0),(NULL, 'z', @mvalue, 28500),(NULL, 'p1', @mvalue, 0),(NULL, 'p2', @mvalue, 0),(NULL, 'px', @mvalue, 25600),(NULL, 'py', @mvalue, 25600),(NULL, 'pz', @mvalue, 0);SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`values` (`idx`, `value`, `mset`, `parameter`) VALUES (NULL, 1688,0, NULL); SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`coordinates` (`index`, `name`, `correspondingvalue`, `coordinate`) VALUES (NULL, 'x', @mvalue, 900),(NULL, 'y', @mvalue, 0),(NULL, 'z', @mvalue, 28500),(NULL, 'p1', @mvalue, 0),(NULL, 'p2', @mvalue, 0),(NULL, 'px', @mvalue, 25600),(NULL, 'py', @mvalue, 25600),(NULL, 'pz', @mvalue, 0);SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`values` (`idx`, `value`, `mset`, `parameter`) VALUES (NULL, 1713,0, NULL); SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`coordinates` (`index`, `name`, `correspondingvalue`, `coordinate`) VALUES (NULL, 'x', @mvalue, 1000),(NULL, 'y', @mvalue, 0),(NULL, 'z', @mvalue, 28500),(NULL, 'p1', @mvalue, 0),(NULL, 'p2', @mvalue, 0),(NULL, 'px', @mvalue, 25600),(NULL, 'py', @mvalue, 25600),(NULL, 'pz', @mvalue, 0);SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`values` (`idx`, `value`, `mset`, `parameter`) VALUES (NULL, 1800,0, NULL); SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`coordinates` (`index`, `name`, `correspondingvalue`, `coordinate`) VALUES (NULL, 'x', @mvalue, 1100),(NULL, 'y', @mvalue, 0),(NULL, 'z', @mvalue, 28500),(NULL, 'p1', @mvalue, 0),(NULL, 'p2', @mvalue, 0),(NULL, 'px', @mvalue, 25600),(NULL, 'py', @mvalue, 25600),(NULL, 'pz', @mvalue, 0);SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`values` (`idx`, `value`, `mset`, `parameter`) VALUES (NULL, 1689,0, NULL); SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`coordinates` (`index`, `name`, `correspondingvalue`, `coordinate`) VALUES (NULL, 'x', @mvalue, 1200),(NULL, 'y', @mvalue, 0),(NULL, 'z', @mvalue, 28500),(NULL, 'p1', @mvalue, 0),(NULL, 'p2', @mvalue, 0),(NULL, 'px', @mvalue, 25600),(NULL, 'py', @mvalue, 25600),(NULL, 'pz', @mvalue, 0);SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`values` (`idx`, `value`, `mset`, `parameter`) VALUES (NULL, 1737,0, NULL); SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`coordinates` (`index`, `name`, `correspondingvalue`, `coordinate`) VALUES (NULL, 'x', @mvalue, 1300),(NULL, 'y', @mvalue, 0),(NULL, 'z', @mvalue, 28500),(NULL, 'p1', @mvalue, 0),(NULL, 'p2', @mvalue, 0),(NULL, 'px', @mvalue, 25600),(NULL, 'py', @mvalue, 25600),(NULL, 'pz', @mvalue, 0);SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`values` (`idx`, `value`, `mset`, `parameter`) VALUES (NULL, 1393,0, NULL); SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`coordinates` (`index`, `name`, `correspondingvalue`, `coordinate`) VALUES (NULL, 'x', @mvalue, 1400),(NULL, 'y', @mvalue, 0),(NULL, 'z', @mvalue, 28500),(NULL, 'p1', @mvalue, 0),(NULL, 'p2', @mvalue, 0),(NULL, 'px', @mvalue, 25600),(NULL, 'py', @mvalue, 25600),(NULL, 'pz', @mvalue, 0);SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`values` (`idx`, `value`, `mset`, `parameter`) VALUES (NULL, 1388,0, NULL); SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`coordinates` (`index`, `name`, `correspondingvalue`, `coordinate`) VALUES (NULL, 'x', @mvalue, 1500),(NULL, 'y', @mvalue, 0),(NULL, 'z', @mvalue, 28500),(NULL, 'p1', @mvalue, 0),(NULL, 'p2', @mvalue, 0),(NULL, 'px', @mvalue, 25600),(NULL, 'py', @mvalue, 25600),(NULL, 'pz', @mvalue, 0);SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`values` (`idx`, `value`, `mset`, `parameter`) VALUES (NULL, 1462,0, NULL); SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`coordinates` (`index`, `name`, `correspondingvalue`, `coordinate`) VALUES (NULL, 'x', @mvalue, 1600),(NULL, 'y', @mvalue, 0),(NULL, 'z', @mvalue, 28500),(NULL, 'p1', @mvalue, 0),(NULL, 'p2', @mvalue, 0),(NULL, 'px', @mvalue, 25600),(NULL, 'py', @mvalue, 25600),(NULL, 'pz', @mvalue, 0);SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`values` (`idx`, `value`, `mset`, `parameter`) VALUES (NULL, 1578,0, NULL); SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`coordinates` (`index`, `name`, `correspondingvalue`, `coordinate`) VALUES (NULL, 'x', @mvalue, 1700),(NULL, 'y', @mvalue, 0),(NULL, 'z', @mvalue, 28500),(NULL, 'p1', @mvalue, 0),(NULL, 'p2', @mvalue, 0),(NULL, 'px', @mvalue, 25600),(NULL, 'py', @mvalue, 25600),(NULL, 'pz', @mvalue, 0);SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`values` (`idx`, `value`, `mset`, `parameter`) VALUES (NULL, 1497,0, NULL); SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`coordinates` (`index`, `name`, `correspondingvalue`, `coordinate`) VALUES (NULL, 'x', @mvalue, 1800),(NULL, 'y', @mvalue, 0),(NULL, 'z', @mvalue, 28500),(NULL, 'p1', @mvalue, 0),(NULL, 'p2', @mvalue, 0),(NULL, 'px', @mvalue, 25600),(NULL, 'py', @mvalue, 25600),(NULL, 'pz', @mvalue, 0);SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`values` (`idx`, `value`, `mset`, `parameter`) VALUES (NULL, 1614,0, NULL); SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`coordinates` (`index`, `name`, `correspondingvalue`, `coordinate`) VALUES (NULL, 'x', @mvalue, 1900),(NULL, 'y', @mvalue, 0),(NULL, 'z', @mvalue, 28500),(NULL, 'p1', @mvalue, 0),(NULL, 'p2', @mvalue, 0),(NULL, 'px', @mvalue, 25600),(NULL, 'py', @mvalue, 25600),(NULL, 'pz', @mvalue, 0);SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`values` (`idx`, `value`, `mset`, `parameter`) VALUES (NULL, 1708,0, NULL); SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`coordinates` (`index`, `name`, `correspondingvalue`, `coordinate`) VALUES (NULL, 'x', @mvalue, 2000),(NULL, 'y', @mvalue, 0),(NULL, 'z', @mvalue, 28500),(NULL, 'p1', @mvalue, 0),(NULL, 'p2', @mvalue, 0),(NULL, 'px', @mvalue, 25600),(NULL, 'py', @mvalue, 25600),(NULL, 'pz', @mvalue, 0);SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`values` (`idx`, `value`, `mset`, `parameter`) VALUES (NULL, 1622,0, NULL); SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`coordinates` (`index`, `name`, `correspondingvalue`, `coordinate`) VALUES (NULL, 'x', @mvalue, 2100),(NULL, 'y', @mvalue, 0),(NULL, 'z', @mvalue, 28500),(NULL, 'p1', @mvalue, 0),(NULL, 'p2', @mvalue, 0),(NULL, 'px', @mvalue, 25600),(NULL, 'py', @mvalue, 25600),(NULL, 'pz', @mvalue, 0);SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`values` (`idx`, `value`, `mset`, `parameter`) VALUES (NULL, 1705,0, NULL); SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`coordinates` (`index`, `name`, `correspondingvalue`, `coordinate`) VALUES (NULL, 'x', @mvalue, 2200),(NULL, 'y', @mvalue, 0),(NULL, 'z', @mvalue, 28500),(NULL, 'p1', @mvalue, 0),(NULL, 'p2', @mvalue, 0),(NULL, 'px', @mvalue, 25600),(NULL, 'py', @mvalue, 25600),(NULL, 'pz', @mvalue, 0);SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`values` (`idx`, `value`, `mset`, `parameter`) VALUES (NULL, 1644,0, NULL); SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`coordinates` (`index`, `name`, `correspondingvalue`, `coordinate`) VALUES (NULL, 'x', @mvalue, 2300),(NULL, 'y', @mvalue, 0),(NULL, 'z', @mvalue, 28500),(NULL, 'p1', @mvalue, 0),(NULL, 'p2', @mvalue, 0),(NULL, 'px', @mvalue, 25600),(NULL, 'py', @mvalue, 25600),(NULL, 'pz', @mvalue, 0);SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`values` (`idx`, `value`, `mset`, `parameter`) VALUES (NULL, 1746,0, NULL); SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`coordinates` (`index`, `name`, `correspondingvalue`, `coordinate`) VALUES (NULL, 'x', @mvalue, 2400),(NULL, 'y', @mvalue, 0),(NULL, 'z', @mvalue, 28500),(NULL, 'p1', @mvalue, 0),(NULL, 'p2', @mvalue, 0),(NULL, 'px', @mvalue, 25600),(NULL, 'py', @mvalue, 25600),(NULL, 'pz', @mvalue, 0);SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`values` (`idx`, `value`, `mset`, `parameter`) VALUES (NULL, 1759,0, NULL); SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`coordinates` (`index`, `name`, `correspondingvalue`, `coordinate`) VALUES (NULL, 'x', @mvalue, 2500),(NULL, 'y', @mvalue, 0),(NULL, 'z', @mvalue, 28500),(NULL, 'p1', @mvalue, 0),(NULL, 'p2', @mvalue, 0),(NULL, 'px', @mvalue, 25600),(NULL, 'py', @mvalue, 25600),(NULL, 'pz', @mvalue, 0);SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`values` (`idx`, `value`, `mset`, `parameter`) VALUES (NULL, 1789,0, NULL); SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`coordinates` (`index`, `name`, `correspondingvalue`, `coordinate`) VALUES (NULL, 'x', @mvalue, 2600),(NULL, 'y', @mvalue, 0),(NULL, 'z', @mvalue, 28500),(NULL, 'p1', @mvalue, 0),(NULL, 'p2', @mvalue, 0),(NULL, 'px', @mvalue, 25600),(NULL, 'py', @mvalue, 25600),(NULL, 'pz', @mvalue, 0);SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`values` (`idx`, `value`, `mset`, `parameter`) VALUES (NULL, 1858,0, NULL); SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`coordinates` (`index`, `name`, `correspondingvalue`, `coordinate`) VALUES (NULL, 'x', @mvalue, 2700),(NULL, 'y', @mvalue, 0),(NULL, 'z', @mvalue, 28500),(NULL, 'p1', @mvalue, 0),(NULL, 'p2', @mvalue, 0),(NULL, 'px', @mvalue, 25600),(NULL, 'py', @mvalue, 25600),(NULL, 'pz', @mvalue, 0);SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`values` (`idx`, `value`, `mset`, `parameter`) VALUES (NULL, 1783,0, NULL); SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`coordinates` (`index`, `name`, `correspondingvalue`, `coordinate`) VALUES (NULL, 'x', @mvalue, 2800),(NULL, 'y', @mvalue, 0),(NULL, 'z', @mvalue, 28500),(NULL, 'p1', @mvalue, 0),(NULL, 'p2', @mvalue, 0),(NULL, 'px', @mvalue, 25600),(NULL, 'py', @mvalue, 25600),(NULL, 'pz', @mvalue, 0);SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`values` (`idx`, `value`, `mset`, `parameter`) VALUES (NULL, 1642,0, NULL); SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`coordinates` (`index`, `name`, `correspondingvalue`, `coordinate`) VALUES (NULL, 'x', @mvalue, 2900),(NULL, 'y', @mvalue, 0),(NULL, 'z', @mvalue, 28500),(NULL, 'p1', @mvalue, 0),(NULL, 'p2', @mvalue, 0),(NULL, 'px', @mvalue, 25600),(NULL, 'py', @mvalue, 25600),(NULL, 'pz', @mvalue, 0);SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`values` (`idx`, `value`, `mset`, `parameter`) VALUES (NULL, 1683,0, NULL); SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`coordinates` (`index`, `name`, `correspondingvalue`, `coordinate`) VALUES (NULL, 'x', @mvalue, 3000),(NULL, 'y', @mvalue, 0),(NULL, 'z', @mvalue, 28500),(NULL, 'p1', @mvalue, 0),(NULL, 'p2', @mvalue, 0),(NULL, 'px', @mvalue, 25600),(NULL, 'py', @mvalue, 25600),(NULL, 'pz', @mvalue, 0);SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`values` (`idx`, `value`, `mset`, `parameter`) VALUES (NULL, 1719,0, NULL); SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`coordinates` (`index`, `name`, `correspondingvalue`, `coordinate`) VALUES (NULL, 'x', @mvalue, 3100),(NULL, 'y', @mvalue, 0),(NULL, 'z', @mvalue, 28500),(NULL, 'p1', @mvalue, 0),(NULL, 'p2', @mvalue, 0),(NULL, 'px', @mvalue, 25600),(NULL, 'py', @mvalue, 25600),(NULL, 'pz', @mvalue, 0);SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`values` (`idx`, `value`, `mset`, `parameter`) VALUES (NULL, 1774,0, NULL); SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`coordinates` (`index`, `name`, `correspondingvalue`, `coordinate`) VALUES (NULL, 'x', @mvalue, 3200),(NULL, 'y', @mvalue, 0),(NULL, 'z', @mvalue, 28500),(NULL, 'p1', @mvalue, 0),(NULL, 'p2', @mvalue, 0),(NULL, 'px', @mvalue, 25600),(NULL, 'py', @mvalue, 25600),(NULL, 'pz', @mvalue, 0);SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`values` (`idx`, `value`, `mset`, `parameter`) VALUES (NULL, 1806,0, NULL); SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`coordinates` (`index`, `name`, `correspondingvalue`, `coordinate`) VALUES (NULL, 'x', @mvalue, 3300),(NULL, 'y', @mvalue, 0),(NULL, 'z', @mvalue, 28500),(NULL, 'p1', @mvalue, 0),(NULL, 'p2', @mvalue, 0),(NULL, 'px', @mvalue, 25600),(NULL, 'py', @mvalue, 25600),(NULL, 'pz', @mvalue, 0);SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`values` (`idx`, `value`, `mset`, `parameter`) VALUES (NULL, 1867,0, NULL); SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`coordinates` (`index`, `name`, `correspondingvalue`, `coordinate`) VALUES (NULL, 'x', @mvalue, 3400),(NULL, 'y', @mvalue, 0),(NULL, 'z', @mvalue, 28500),(NULL, 'p1', @mvalue, 0),(NULL, 'p2', @mvalue, 0),(NULL, 'px', @mvalue, 25600),(NULL, 'py', @mvalue, 25600),(NULL, 'pz', @mvalue, 0);SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`values` (`idx`, `value`, `mset`, `parameter`) VALUES (NULL, 1781,0, NULL); SET @mvalue = (SELECT (LAST_INSERT_ID())); INSERT INTO `messdaten`.`coordinates` (`index`, `name`, `correspondingvalue`, `coordinate`) VALUES (NULL, 'x', @mvalue, 3500),(NULL, 'y', @mvalue, 0),(NULL, 'z', @mvalue, 28500),(NULL, 'p1', @mvalue, 0),(NULL, 'p2', @mvalue, 0),(NULL, 'px', @mvalue, 25600),(NULL, 'py', @mvalue, 25600),(NULL, 'pz', @mvalue, 0);					


lg Boldar
Nersgatt
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1581
Erhaltene Danke: 279


Delphi 10 Seattle Prof.
BeitragVerfasst: Di 15.07.14 11:46 
Hast Du es mal mit einem INSERT DELAYED versucht?
dev.mysql.com/doc/re.../insert-delayed.html

_________________
Gruß, Jens
Zuerst ignorieren sie dich, dann lachen sie über dich, dann bekämpfen sie dich und dann gewinnst du. (Mahatma Gandhi)

Für diesen Beitrag haben gedankt: Boldar
Boldar Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1555
Erhaltene Danke: 70

Win7 Enterprise 64bit, Win XP SP2
Turbo Delphi
BeitragVerfasst: Di 15.07.14 12:50 
Das Problem hierbei ist ja, dass ich in den späteren inserts den (Autoinkrement-)Primary key der ersten brauche, deshalb die ersten nicht delayen kann. Aber zumindest mit den späteren werde ich das gleich mal ausprobieren. Aber, wie gesagt: es dauert ja nicht das insert so lange, sondern das mysql_next_result. Die restliche Laufzeit ist im Bereich weniger ms und da hängt es jedesmal so um die 12s.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19272
Erhaltene Danke: 1740

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Di 15.07.14 14:27 
Kannst du nicht stored procedures nutzen? Gerade weil du mit den Werten aus dem ersten insert weiterarbeitest, sollte das doch gehen.

Für diesen Beitrag haben gedankt: Boldar
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Di 15.07.14 14:43 
Statt der Schleife könntest du auch mysql_store_result() nehmen (siehe Beispiel), aber das tut an der Stelle wenig zur Sache. Dürfte intern gleich aussehen. EDIT: next_result ist der Resultset-Iterator, nicht die Zeilen im Resultset... der Vorschlag ist also Quatsch.

Das klingt aber trotzdem nach komischem Design.
Gibts die Query auch irgendwo in menschenlesbar?

Achja und:
user profile iconBoldar hat folgendes geschrieben Zum zitierten Posting springen:
Leider geht in der schleife aber auch >90% der zeit verloren.
Von wie viel Zeit reden wir eigentlich? Schlechte Queries können natürlich beliebig langsam werden (und deine sieht nach mehr Parse-Zeit und IO als alles andere aus), aber ohne Zahlen kann ich da grad wenig sagen.

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."


Zuletzt bearbeitet von Martok am Di 15.07.14 15:54, insgesamt 2-mal bearbeitet

Für diesen Beitrag haben gedankt: Boldar
Nersgatt
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1581
Erhaltene Danke: 279


Delphi 10 Seattle Prof.
BeitragVerfasst: Di 15.07.14 14:48 
user profile iconMartok hat folgendes geschrieben Zum zitierten Posting springen:
Von wie viel Zeit reden wir eigentlich? Schlechte Queries können natürlich beliebig langsam werden (und deine sieht nach mehr Parse-Zeit und IO als alles andere aus), aber ohne Zahlen kann ich da grad wenig sagen.


Hat er doch oben geschrieben. 12 Sekunden. Das ist ja schon ganz was.
Evtentuell wäre es hier hilfreich, auf zwei parametrisierte und präparierte Queries zu setzen, statt die Statements so zu übergeben.

_________________
Gruß, Jens
Zuerst ignorieren sie dich, dann lachen sie über dich, dann bekämpfen sie dich und dann gewinnst du. (Mahatma Gandhi)

Für diesen Beitrag haben gedankt: Boldar
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Di 15.07.14 15:25 
user profile iconNersgatt hat folgendes geschrieben Zum zitierten Posting springen:
Hat er doch oben geschrieben. 12 Sekunden. Das ist ja schon ganz was.
Hoppla, hab ich übersehen. :oops:

Wie oft wird die Schleife durchlaufen? Also: wie lang ist die Query, so wie gezeigt oder noch mehr davon? Ggf. könntest du ja mal gucken, welcher Teilausdruck jeweils wie viel Zeit verbrät. Es kann gut sein, dass die SETs ein Resultset haben und dort die ganze Query steht, bis abgeholt wird. Dann wären die 12s deine echte Verarbeitungszeit, da nach dem ersten Insert nix mehr passiert...

EDIT: Ich hab mir die Query mal formatiert.

ausblenden SQL-Anweisung
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
INSERT INTO `messdaten`.`values` (`idx`, `value`, `mset`, `parameter`)
 VALUES (NULL32176,0NULL);
SET @mvalue = (SELECT (LAST_INSERT_ID()));
INSERT INTO `messdaten`.`coordinates` (`index`, `name`, `correspondingvalue`, `coordinate`)
 VALUES (NULL'x', @mvalue, 0),...;
SET @mvalue = (SELECT (LAST_INSERT_ID()));

INSERT INTO `messdaten`.`values` (`idx`, `value`, `mset`, `parameter`)
 VALUES (NULL835,0NULL);
SET @mvalue = (SELECT (LAST_INSERT_ID()));
INSERT INTO `messdaten`.`coordinates` (`index`, `name`, `correspondingvalue`, `coordinate`)
 VALUES (NULL'x', @mvalue, 100),...;
SET @mvalue = (SELECT (LAST_INSERT_ID()));

Da ist erstmal prinzipiell immer das markierte SET übrig. Dann frag ich mich ganz besorgt, warum du als index immer NULL übergibst? Sollte das bei dem Namen nicht eigentlich eine PK+AUTO_INCREMENT-Spalte sein?

Und oben hab ich Quatsch erzählt, more_results brauchst du natürlich trotzdem. Darin allerdings könnte man das Ergebnis mal abholen, vielleicht gibt's ja irgendwelche Meldungen...

Prepared Statements wären natürlich schneller, aber mit der C-API will ich das auch nicht tun müssen...

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."

Für diesen Beitrag haben gedankt: Boldar
Boldar Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1555
Erhaltene Danke: 70

Win7 Enterprise 64bit, Win XP SP2
Turbo Delphi
BeitragVerfasst: Mi 16.07.14 15:15 
Es geht in Prinzip darum, Daten aus einer XML datei in die db zu kriegen.
Die XML-Datei sieht etwa so aus:
ausblenden volle Höhe Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349:
350:
351:
352:
353:
354:
355:
356:
357:
358:
359:
360:
361:
362:
363:
364:
365:
366:
367:
368:
369:
370:
371:
372:
373:
374:
375:
376:
377:
378:
379:
380:
381:
382:
383:
384:
385:
386:
387:
388:
389:
390:
391:
392:
393:
394:
395:
396:
397:
398:
399:
400:
401:
402:
403:
404:
405:
406:
407:
408:
409:
410:
411:
412:
413:
414:
415:
416:
417:
418:
419:
420:
421:
422:
423:
424:
425:
426:
427:
428:
429:
430:
431:
432:
433:
434:
<root>
<p>
<iterations>1</iterations>
<inttime>50</inttime>
<x>0</x>
<y>0</y>
<z>28500</z>
<p1>0</p1>
<p2>0</p2>
<px>25600</px>
<py>25600</py>
<value>32176</value>
</p>
<p>
<iterations>1</iterations>
<inttime>50</inttime>
<x>100</x>
<y>0</y>
<z>28500</z>
<p1>0</p1>
<p2>0</p2>
<px>25600</px>
<py>25600</py>
<value>835</value>
</p>
<p>
<iterations>1</iterations>
<inttime>50</inttime>
<x>200</x>
<y>0</y>
<z>28500</z>
<p1>0</p1>
<p2>0</p2>
<px>25600</px>
<py>25600</py>
<value>903</value>
</p>
<p>
<iterations>1</iterations>
<inttime>50</inttime>
<x>300</x>
<y>0</y>
<z>28500</z>
<p1>0</p1>
<p2>0</p2>
<px>25600</px>
<py>25600</py>
<value>1195</value>
</p>
<p>
<iterations>1</iterations>
<inttime>50</inttime>
<x>400</x>
<y>0</y>
<z>28500</z>
<p1>0</p1>
<p2>0</p2>
<px>25600</px>
<py>25600</py>
<value>1251</value>
</p>
<p>
<iterations>1</iterations>
<inttime>50</inttime>
<x>500</x>
<y>0</y>
<z>28500</z>
<p1>0</p1>
<p2>0</p2>
<px>25600</px>
<py>25600</py>
<value>1271</value>
</p>
<p>
<iterations>1</iterations>
<inttime>50</inttime>
<x>600</x>
<y>0</y>
<z>28500</z>
<p1>0</p1>
<p2>0</p2>
<px>25600</px>
<py>25600</py>
<value>1223</value>
</p>
<p>
<iterations>1</iterations>
<inttime>50</inttime>
<x>700</x>
<y>0</y>
<z>28500</z>
<p1>0</p1>
<p2>0</p2>
<px>25600</px>
<py>25600</py>
<value>1428</value>
</p>
<p>
<iterations>1</iterations>
<inttime>50</inttime>
<x>800</x>
<y>0</y>
<z>28500</z>
<p1>0</p1>
<p2>0</p2>
<px>25600</px>
<py>25600</py>
<value>1656</value>
</p>
<p>
<iterations>1</iterations>
<inttime>50</inttime>
<x>900</x>
<y>0</y>
<z>28500</z>
<p1>0</p1>
<p2>0</p2>
<px>25600</px>
<py>25600</py>
<value>1688</value>
</p>
<p>
<iterations>1</iterations>
<inttime>50</inttime>
<x>1000</x>
<y>0</y>
<z>28500</z>
<p1>0</p1>
<p2>0</p2>
<px>25600</px>
<py>25600</py>
<value>1713</value>
</p>
<p>
<iterations>1</iterations>
<inttime>50</inttime>
<x>1100</x>
<y>0</y>
<z>28500</z>
<p1>0</p1>
<p2>0</p2>
<px>25600</px>
<py>25600</py>
<value>1800</value>
</p>
<p>
<iterations>1</iterations>
<inttime>50</inttime>
<x>1200</x>
<y>0</y>
<z>28500</z>
<p1>0</p1>
<p2>0</p2>
<px>25600</px>
<py>25600</py>
<value>1689</value>
</p>
<p>
<iterations>1</iterations>
<inttime>50</inttime>
<x>1300</x>
<y>0</y>
<z>28500</z>
<p1>0</p1>
<p2>0</p2>
<px>25600</px>
<py>25600</py>
<value>1737</value>
</p>
<p>
<iterations>1</iterations>
<inttime>50</inttime>
<x>1400</x>
<y>0</y>
<z>28500</z>
<p1>0</p1>
<p2>0</p2>
<px>25600</px>
<py>25600</py>
<value>1393</value>
</p>
<p>
<iterations>1</iterations>
<inttime>50</inttime>
<x>1500</x>
<y>0</y>
<z>28500</z>
<p1>0</p1>
<p2>0</p2>
<px>25600</px>
<py>25600</py>
<value>1388</value>
</p>
<p>
<iterations>1</iterations>
<inttime>50</inttime>
<x>1600</x>
<y>0</y>
<z>28500</z>
<p1>0</p1>
<p2>0</p2>
<px>25600</px>
<py>25600</py>
<value>1462</value>
</p>
<p>
<iterations>1</iterations>
<inttime>50</inttime>
<x>1700</x>
<y>0</y>
<z>28500</z>
<p1>0</p1>
<p2>0</p2>
<px>25600</px>
<py>25600</py>
<value>1578</value>
</p>
<p>
<iterations>1</iterations>
<inttime>50</inttime>
<x>1800</x>
<y>0</y>
<z>28500</z>
<p1>0</p1>
<p2>0</p2>
<px>25600</px>
<py>25600</py>
<value>1497</value>
</p>
<p>
<iterations>1</iterations>
<inttime>50</inttime>
<x>1900</x>
<y>0</y>
<z>28500</z>
<p1>0</p1>
<p2>0</p2>
<px>25600</px>
<py>25600</py>
<value>1614</value>
</p>
<p>
<iterations>1</iterations>
<inttime>50</inttime>
<x>2000</x>
<y>0</y>
<z>28500</z>
<p1>0</p1>
<p2>0</p2>
<px>25600</px>
<py>25600</py>
<value>1708</value>
</p>
<p>
<iterations>1</iterations>
<inttime>50</inttime>
<x>2100</x>
<y>0</y>
<z>28500</z>
<p1>0</p1>
<p2>0</p2>
<px>25600</px>
<py>25600</py>
<value>1622</value>
</p>
<p>
<iterations>1</iterations>
<inttime>50</inttime>
<x>2200</x>
<y>0</y>
<z>28500</z>
<p1>0</p1>
<p2>0</p2>
<px>25600</px>
<py>25600</py>
<value>1705</value>
</p>
<p>
<iterations>1</iterations>
<inttime>50</inttime>
<x>2300</x>
<y>0</y>
<z>28500</z>
<p1>0</p1>
<p2>0</p2>
<px>25600</px>
<py>25600</py>
<value>1644</value>
</p>
<p>
<iterations>1</iterations>
<inttime>50</inttime>
<x>2400</x>
<y>0</y>
<z>28500</z>
<p1>0</p1>
<p2>0</p2>
<px>25600</px>
<py>25600</py>
<value>1746</value>
</p>
<p>
<iterations>1</iterations>
<inttime>50</inttime>
<x>2500</x>
<y>0</y>
<z>28500</z>
<p1>0</p1>
<p2>0</p2>
<px>25600</px>
<py>25600</py>
<value>1759</value>
</p>
<p>
<iterations>1</iterations>
<inttime>50</inttime>
<x>2600</x>
<y>0</y>
<z>28500</z>
<p1>0</p1>
<p2>0</p2>
<px>25600</px>
<py>25600</py>
<value>1789</value>
</p>
<p>
<iterations>1</iterations>
<inttime>50</inttime>
<x>2700</x>
<y>0</y>
<z>28500</z>
<p1>0</p1>
<p2>0</p2>
<px>25600</px>
<py>25600</py>
<value>1858</value>
</p>
<p>
<iterations>1</iterations>
<inttime>50</inttime>
<x>2800</x>
<y>0</y>
<z>28500</z>
<p1>0</p1>
<p2>0</p2>
<px>25600</px>
<py>25600</py>
<value>1783</value>
</p>
<p>
<iterations>1</iterations>
<inttime>50</inttime>
<x>2900</x>
<y>0</y>
<z>28500</z>
<p1>0</p1>
<p2>0</p2>
<px>25600</px>
<py>25600</py>
<value>1642</value>
</p>
<p>
<iterations>1</iterations>
<inttime>50</inttime>
<x>3000</x>
<y>0</y>
<z>28500</z>
<p1>0</p1>
<p2>0</p2>
<px>25600</px>
<py>25600</py>
<value>1683</value>
</p>
<p>
<iterations>1</iterations>
<inttime>50</inttime>
<x>3100</x>
<y>0</y>
<z>28500</z>
<p1>0</p1>
<p2>0</p2>
<px>25600</px>
<py>25600</py>
<value>1719</value>
</p>
<p>
<iterations>1</iterations>
<inttime>50</inttime>
<x>3200</x>
<y>0</y>
<z>28500</z>
<p1>0</p1>
<p2>0</p2>
<px>25600</px>
<py>25600</py>
<value>1774</value>
</p>
<p>
<iterations>1</iterations>
<inttime>50</inttime>
<x>3300</x>
<y>0</y>
<z>28500</z>
<p1>0</p1>
<p2>0</p2>
<px>25600</px>
<py>25600</py>
<value>1806</value>
</p>
<p>
<iterations>1</iterations>
<inttime>50</inttime>
<x>3400</x>
<y>0</y>
<z>28500</z>
<p1>0</p1>
<p2>0</p2>
<px>25600</px>
<py>25600</py>
<value>1867</value>
</p>
<p>
<iterations>1</iterations>
<inttime>50</inttime>
<x>3500</x>
<y>0</y>
<z>28500</z>
<p1>0</p1>
<p2>0</p2>
<px>25600</px>
<py>25600</py>
<value>1781</value>
</p>
</root>


Nur halt mit viel mehr Einträgen.

In der Datenbank erstelle ich erst einen Eintrag in einer Set-Tabelle einmalig für die Datei.
Dann Erstelle ich für jedes <p> einen eintrag in der "values" tabelle und für jeden Eintrag darin dann Einträge in dercoordinaten tabelle halt mit x, y, z usw.
Index ist autoinkrement, jam könnte ich also ganz weglassen, sollte aber keinen unterschied machen. Da die spalte nicht nullable ist, nimmt er automatisch schon einen autoinkrement index wenn es null ist.
Die xml Datei lese ich übrigens von Hand, ohne XML-Parser, da ich mich darauf verlassen kann dass die genau so kommt. Das klappt auch super-nehme ich das Datenbank einfügen raus, läuft eine Datei mit über einer million Einträgen in einigen sekunden durch.
Das Query bastele ich wie folgt zusammen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
    if s.StartsWith('</p>'then
    begin
      bquery := bquery+' INSERT INTO `messdaten`.`values` (`idx`, `value`, `mset`, `parameter`) VALUES (NULL, '+inttostr(value)+','+inttostr(mset)+', NULL); SET @mvalue = (SELECT (LAST_INSERT_ID()));'+
'INSERT INTO `messdaten`.`coordinates` (`index`, `name`, `correspondingvalue`, `coordinate`) VALUES ';
      mname := 'x' ; mcoord := inttostr(x );bquery := bquery + '(NULL, '''+mname+''', @mvalue, '+mcoord+'),';
      mname := 'y' ; mcoord := inttostr(y );bquery := bquery + '(NULL, '''+mname+''', @mvalue, '+mcoord+'),';
      mname := 'z' ; mcoord := inttostr(z );bquery := bquery + '(NULL, '''+mname+''', @mvalue, '+mcoord+'),';
      mname := 'p1'; mcoord := inttostr(p1);bquery := bquery + '(NULL, '''+mname+''', @mvalue, '+mcoord+'),';
      mname := 'p2'; mcoord := inttostr(p2);bquery := bquery + '(NULL, '''+mname+''', @mvalue, '+mcoord+'),';
      mname := 'px'; mcoord := inttostr(px);bquery := bquery + '(NULL, '''+mname+''', @mvalue, '+mcoord+'),';
      mname := 'py'; mcoord := inttostr(py);bquery := bquery + '(NULL, '''+mname+''', @mvalue, '+mcoord+'),';
      mname := 'pz'; mcoord := inttostr(pz);bquery := bquery + '(NULL, '''+mname+''', @mvalue, '+mcoord+');';
      if (length(bquery)>200000then
      begin
        insert (bquery);
        bquery := '';
      end;



mit
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
procedure insert (query: AnsiString);
var
  I: Integer;
  res: PMYSQL_RES;
  error: string;
  count: integer;
  var st, st2, sta, sta2: cardinal;
begin

  st := gettickcount;
  mysql_real_query(_myCon, PAnsiChar(query), Length(query));
  form2.err.Lines.Add('query:   '+inttostr(gettickcount-st));
  st2 := gettickcount;
  sta:=0;sta2:=0;
  while ( mysql_more_results(_myCon)) do
  begin
    sta:=sta+gettickcount-st2;
    //form2.err.Lines.Add('more:    '+inttostr(gettickcount-st2));
    st2:=gettickcount;
    mysql_next_result(_myCon);
    //form2.err.Lines.Add('next:    '+inttostr(gettickcount-st2));
    sta2:=sta2+gettickcount-st2;
    st2:=gettickcount;
  end;
  form2.err.Lines.Add('results: '+inttostr(gettickcount-st));
  form2.err.Lines.Add('next:    '+inttostr(sta2));
  form2.err.Lines.Add('more:    '+inttostr(sta));
  error := mysql_error(_myCon);
  if error<>'' then
  begin
    form2.err.Lines.Add('===================');
    showmessage (error);
    form2.err.Lines.Add(error);
    form2.err.Lines.Add(query);
    form2.err.Lines.Add('===================');
  end;
end;
ene
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 779
Erhaltene Danke: 1

Vista, XP, W2K
Delphi, .Net, Deutsch und Englisch
BeitragVerfasst: Do 17.07.14 10:44 
Moin,

So ganz verstanden habe ich alle Details nicht, aber was spricht gegen eine stored procedure aus MySQL direkt? Weil du per Remote dran hängst und die DB damit keinen Zugang zur Datei hat?
Wenn das ginge, würde ich Dir das hier ans Herz legen. Normalerweise würde ich auch vermuten, dass man so etwas per Cron-Job direkt aus MySQL macht und nicht über Delphi geht.

Ob MySQL ein direktes öffnen der Datei erlaubt, weiß ich leider nicht, aber das wäre dann die schnellste und einfachste Variante a la:

ausblenden SQL-Anweisung
1:
2:
3:
4:
5:
6:
7:
8:
9:
SELECT * FROM Tabelle
UPDATE Tabelle
SET XML =(SELECT * FROM OPENROWSET(
   BULK 'C:\Datei.txt',
           SINGLE_BLOB
AS XML
)
WHERE IntCol = 1;
GO


Hat es einen besonderen Grund, dass die Messdaten geordnet seien müssen? Ich würde sonst einfach ein Bulk_Insert machen und nur die einheitliche "VersuchsID" mitgeben, denn die Ordnung der Tabelle ist Lachs, so lange man weiß, wozu die Daten gehören.

Falls es um die einfache Auswertung jeweils nur einer Datei geht, würde ich eine andere Variante vorschlagen, da werden aber keine Daten gespeichert, sondern es gibt nur Momentaufnahmen.

_________________
Wir, die guten Willens sind, geführt von Ahnungslosen, Versuchen für die Undankbaren das Unmögliche zu vollbringen.
Wir haben soviel mit so wenig so lange versucht, daß wir jetzt qualifiziert sind, fast alles mit Nichts zu bewerkstelligen.