Thema: Delphi MySQL sau lahm

Einzelnen Beitrag anzeigen

Benutzerbild von cheatzs
cheatzs

Registriert seit: 31. Aug 2003
Ort: Altenburg
81 Beiträge
 
#1

MySQL sau lahm

  Alt 29. Sep 2004, 18:01
Hi Leutz,
greife mit meinem Programm wie in Delphi-Source erklärt mit MySQL direct auf eine MySQL Datenbank zu.
Leider geht das echt lahm (hab 500 Mhz).
Weiß aber nicht an was das liegt. Um ca. 100 Datensätze hinzuzufügen (einschließlich Berechnungen von DateiHash MD5) brauch ich ca. 6 sek.

Genauso beim Laden verschiedener Datensätze.
Ich lasse mir diese in einem TListView (OwnerData) anzeigen. Je nachdem welcher Datensatz gerade gebraucht wird, wird derjenige eben dann geladen. Dauer auch hier für gesamten Aufbau der Tabelle ca. 3 sek.

Hier mal meine Zugriffs bzw. Schreib und Create-Prozeduren:

Delphi-Quellcode:
//Verbinden

SQLConnection:= TMysqlClient.Create;
  try
    with SQLConnection do
    begin
      Host := *Hostname*;
      Port := 3306;
      User := *User*;
      Password := *Passwort*;
      Db := *Datenbankname*;
      Connect;
    end;

//Hinzufügen

 if SQLConnection.Connected then
  begin
    DateSeparator := '-';
    ShortDateFormat := 'yyyy-mm-dd hh:mm:ss';
    SQLConnection.Query('INSERT INTO '+Table+' (sName, sPath, cLength, wPriority, wState, dtDate, sHash, cLastTimeSend, cDownloaded, wLevel) VALUES ('''+AFile.sName+''', '''+EscapeStr(AFile.sPath)+''', '+inttostr(AFile.cLength)+', '+inttostr(AFile.wPriority)+', '+inttostr(AFile.wState)+', '''+datetostr(AFile.dtDate)+''', '''+AFile.sHash+''', '+inttostr(AFile.cLastTimeSend)+', '+inttostr(AFile.cDownloaded)+ ', '+inttostr(AFile.wLevel)+')',FALSE,fExecuting);
    if Table = conWorkUnitdb then
      SQLConnection.Query('INSERT INTO wr_relation (sWorkUnitHash) VALUES ('''+AFile.sHash+''');',FALSE,fExecuting);
  end;

//Auslesen

if SQLConnection.Connected then
  begin
    if Assigned(SQLResult) then
      FreeAndNil(SQLResult);
    SQLResult := SQLConnection.Query('SELECT * FROM '+Table+' WHERE sHash = '''+sHash+''';',TRUE,fExecuting);
    result.sHash := '';
    if Assigned(SQLResult) then
    begin
      with SQLResult do
      begin
        result.sName := FieldValueByName('sName');
        result.sPath := FieldValueByName('sPath');
        result.cLength := StrToInt(FieldValueByName('cLength'));
        result.wPriority := StrToInt(FieldValueByName('wPriority'));
        result.wState := StrToInt(FieldValueByName('wState'));
        result.dtDate := StrToDateTime(FieldValueByName('dtDate'));
        result.cLastTimeSend := StrToInt(FieldValueByName('cLastTimeSend'));
        result.cDownloaded := StrToInt(FieldValueByName('cDownloaded'));
        result.wLevel := StrToInt(FieldValueByName('wLevel'));
        result.sHash := FieldValueByName('sHash');
      end;
    end
    else
      if not fExecuting then
        showmessage(SQLConnection.LastError);
  end;
Kann das an meinem Computer liegen? 500mhz 192mb RAM MySQL 4.018

Sind die Komponenten vielleicht so langsam (Zeos hab ich schon probiert ... ist noch langsamer .. dauert ca. 1 Minute)

Kann mir das einfach nicht erklären...

Gibts vielleicht schnellere Datenbanken? Paradox, dBase, FoxPro ?

Vielen Dank schon mal im Vorraus

Bye
Thomas Low
THX und viel Spaß beim Coden
Cheatzs
  Mit Zitat antworten Zitat