Reputation: 10828
Is it bad to execute MySQL query every 50ms in the loop?
For example:
while(1) {
sleep(0.05)
$bool = do_check();
if ($bool) { ... }
}
function do_check() {
$sql1 = "select .... ";
$sql2 = "select .... ";
some maths formula;
return true for false;
}
It is a Call Centre product I am developing. It has to check how many agents are free and how many calls is dialled and then make a decision to dial more calls or not through API.
Upvotes: 0
Views: 163
Reputation: 72626
I think that it would be better to use a database trigger that will notify your application when the specific condition you want to monitor change status, to implement a similar strategy you need a trigger that will call an User Defined function in MySQL that will call your application through an interprocess communications system (eg. Socket, JMS message) .
Take a look at this site for some example of MySQL UDF.
Upvotes: 1