Sponsored by NuSphere - PHP Software for PHP Application Developers - On Sale This Week for $100



Go Back   PHP-Editors > Linux, Apache, MySQL > MySQL Help

MySQL Help Post any question relating to MySQL here and hopefully someone can help

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 2006-02-17, 12:39 AM
Junior Member
 
Join Date: Feb 2006
Posts: 1
Josh SP
Default

Hi, maybe I'm misunderstanding how REPLACE DELAYED works, but I seem to be having some trouble, and I'm wondering if someone can point me in the right direction. Thanks.

THE SITUATION

I have a PHP/MySQL website that needs to update a value in a table upon each page load. The problem is that this table is also accessed by many SELECT statements, a few of which are unavoidably slow. When one of these slow SELECTs is running and an UPDATE is attempted, my understanding is that the UPDATE locks the table and doesn't let any other SELECTs access the table until the original slow SELECT *and* the UPDATE have completed. I'm witness this occuring, so I'm fairly certain I understand this part correctly. Because of this, whenever a slow SELECT occurs, all the pages on the site (the ones that access the table in question, at least) hang for several seconds.


MY ATTEMPTED SOLUTION

I changed the UPDATE to a REPLACE in order to take advantage of the DELAYED option. I figured this would solve my problems because the table would not be locked to the exclusion of other SELECTS. I thought that the DELAYED option would cause the REPLACE to be nice and let other pending SELECTs access the table.


DOESN'T WORK AS INTENDED

This doesn't seem to be working. The DELAYED option seems to *not* allow other SELECTs to access the table. I have verified this via the mysql command line interface.


SOME DETAILS

Here is the REPLACE SQL I'm using:

REPLACE DELAYED `object_scores` (`object_id`, `hits`, `score`, `weighted_num_votes`, `weighted_vote_sum`) VALUES (172582, 68, 88.01, 3.67371, 36.3206);

Here's the table:

> show create table object_scores;

+----------
| object_scores | CREATE TABLE `object_scores` (
`object_id` int(10) unsigned NOT NULL default '0',
`hits` int(10) unsigned NOT NULL default '0',
`score` float NOT NULL default '0',
`weighted_num_votes` float NOT NULL default '0',
`weighted_vote_sum` float NOT NULL default '0',
PRIMARY KEY (`object_id`),
KEY `hits` (`hits`),
KEY `score` (`score`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
+----------

Any advice would be greatly appreciated. Thanks!
Reply With Quote
Must read Review for Serious PHP Developers


NuSphere PhpED 5.5 : The Staff of php-editors.com recently spent a few days working with NuSphere PhpED 5.5 (a popular PHP IDE) and NuCoder 2.0 (a PHP Encoding Utility), read up on all the details.

Sponsored Links
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 11:16 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.