2 messages in com.mysql.lists.mysql-deRe: Lock/Unlock Tables - Statusabfrag...
FromSent OnAttachments
Tim Hildebrandt01 Feb 2006 07:11 
Rene Fertig01 Feb 2006 07:38 
Subject:Re: Lock/Unlock Tables - Statusabfrage möglich?
From:Rene Fertig (re@renux.de)
Date:02/01/2006 07:38:07 AM
List:com.mysql.lists.mysql-de

Am Mittwoch, 1. Februar 2006 16:12 schrieb Tim Hildebrandt:

INSERT INTO archivtabelle SELECT * FROM produktivtabelle WHERE timestamp < [php: time()] LIMIT 0, 30

Es werden also immer 30 als abgelaufen markierte Datensätze in die Archivtabelle kopiert. Das Problem ist nunmehr, dass bei hoher Serverlast die Archivtabelle ständig automatisch gelockt ist, weil ja dort ein INSERT läuft. Das verlangsamt natürlich den Rest des Scriptdurchlaufs, da zuerst gewartet wird, bis das INSERT durchlaufen wurde.

Vielleicht hilft dir das hier ja:

INSERT DELAYED ...

The DELAYED option for the INSERT statement is a MySQL-specific option that is very useful if you have clients that can't wait for the INSERT to complete. This is a common problem when you use MySQL for logging and you also periodically run SELECT and UPDATE statements that take a long time to complete. DELAYED was introduced in MySQL Version 3.22.15. It is a MySQL extension to SQL-92.

INSERT DELAYED only works with ISAM and MyISAM tables. Note that as MyISAM tables supports concurrent SELECT and INSERT, if there is no free blocks in the middle of the datafile, you very seldom need to use INSERT DELAYED with MyISAM. See section 7.1 MyISAM Tables.

When you use INSERT DELAYED, the client will get an OK at once and the row will be inserted when the table is not in use by any other thread.

...

Mehr im Manual. Aber wie oft machst du den Insert bzw. warum brauchen 30 Datensätze so lange, dass du in Schwierigkeiten kommst?

Ciao, René

----------------------------------------------------------------------