Ajax suggest - bash your SQL server!
We just went live with 6 months worth of work and it has been really smooth considering the amount of changes. Aside from the stupid questions from userland we havent had any major issues. We did however experience some slow downs which we could attribute only to the AJAX suggester tools we had implemented in about 5 different places.
Using CFAJAX we help the users pull out suggestions for property addresses, client names, suburbs, solicitor companies and activity plans. This is going to grow as time goes on.
Simply its a text box that the user starts typing into and then we display a div below it that lists the result of the query matching the input. We quickly realised that each keystroke fires a query on the server. So you could get alot of queries in a VERY short period of time, especially when 10 users are doing it all at the same time. This was blocking up the SQL server and dragging down all services that rely on it. So we had to introduce a timeout on the keypress:
var propertyTimerID = 0;
function timeProperty() {
// if property timer is set if(propertyTimerID) {
// clear it clearTimeout(propertyTimerID);
}
// set it to fire a second from now propertyTimerID = self.setTimeout('getPropertyHelper()', 1000);
}
function getPropertyHelper() {
var thisStreetNo = $('pro_streetNo').value;
var thisAddress = $('pro_fullStreetName').value;
if(thisAddress.length > 2 || thisStreetNo > 2){
DWRUtil.useLoadingMessage('Data Loading...');
//DWRUtil.useLoadingImage(); DWREngine._execute(_ajaxConfig._cfscriptLocation, null, 'getProperty', thisStreetNo, thisAddress, printPropertyResults);
}
}
$('searchAid').style.display = "none";
function printPropertyResults(r){
$('propertyResults').innerHTML = '';
$('searchAid').style.display = "";
$('propertyResults').innerHTML = r;
//alert($('propertyResults').innerHTML); }
$('searchAid').style.display = "none";


There are no comments for this entry.
[Add Comment]