Queued Inserts with MySql using INSERT DELAYED

Have you ever wanted to just perform an operation with MySql and continue on?  If so, you can queue inserts in MySql using the "INSERT DELAYED" command.  INSERT DELAYED queues up a set of inserts and the inserts are written all at once.  This makes the option good for logging.  The inserts are queued in memory, so a failure in the MySql daemon will result in the lose of any unwritten inserts.  A word of warning, INSERT DELAYED is not transactional

Sql Server 2005 will have a feature called Service Broker which will have similar functionaly.  If you need to queue commands right now, another option is to use the Microsoft Message Queue, aka MSMQ.

Wally

1 Comment

  • Cool!



    Is the Service Broker in SQL 2005 a non-transactional sort of insert like the one in MySQL.



    I've always wanted that feature with both inserts and UPDATES... a sort of non-transactional insert or update. For instance, say I'm using a database to dfo real-time tracking how many each pageviews every page in a busy site is views.



    Today may SQL would look something like:



    UPDATE tblPageViews

    SET pageViewCount = pageViewCount = 1

    WHERE pageID = @pageID



    This of course creates a TON of stress on the SQL transaction logs. Since this data is statistical in nature and performance/scalability is more important than making sure the data is 100% correct, I'd like non-transactional updates:



    UPDATE DELAYED tblPageViews

    SET pageViewCount = pageViewCount = 1

    WHERE pageID = @pageID







Comments have been disabled for this content.