scarhand Posted November 30, 2007 Share Posted November 30, 2007 im trying to delete oldest row when a new one is inserted, but apparently this does not work: DELETE FROM shoutbox WHERE id=(SELECT MIN(id) from shoutbox) Quote Link to comment https://forums.phpfreaks.com/topic/79542-delete-oldest-row-by-id-when-inserting-new-one/ Share on other sites More sharing options...
fenway Posted November 30, 2007 Share Posted November 30, 2007 Why would you do that? Quote Link to comment https://forums.phpfreaks.com/topic/79542-delete-oldest-row-by-id-when-inserting-new-one/#findComment-402921 Share on other sites More sharing options...
scarhand Posted November 30, 2007 Author Share Posted November 30, 2007 Why would you do that? well the shoutbox uses ajax and has tons of messages posted every hour i figured doing that might speed it up a little Quote Link to comment https://forums.phpfreaks.com/topic/79542-delete-oldest-row-by-id-when-inserting-new-one/#findComment-402941 Share on other sites More sharing options...
helraizer Posted November 30, 2007 Share Posted November 30, 2007 Why would you do that? well the shoutbox uses ajax and has tons of messages posted every hour i figured doing that might speed it up a little Have them all go into the database, but only the last 10 messages, or whatever in the shoutbox. Would that not work better? Or else you can't go back and read what you've said previously. But based on SQL DELETE TOP 1 FROM `shoutbox` // Then use ASC or DESC for oldest or newest Or might be completely wrong, I'm not sure. That works in theory, though. Quote Link to comment https://forums.phpfreaks.com/topic/79542-delete-oldest-row-by-id-when-inserting-new-one/#findComment-402945 Share on other sites More sharing options...
fenway Posted November 30, 2007 Share Posted November 30, 2007 Why would you do that? well the shoutbox uses ajax and has tons of messages posted every hour i figured doing that might speed it up a little You can always archive it daily, weekly... but don't start having unnecessary write operations for table that's meant to be read all the time Quote Link to comment https://forums.phpfreaks.com/topic/79542-delete-oldest-row-by-id-when-inserting-new-one/#findComment-402951 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.