cancel
Showing results for 
Search instead for 
Did you mean: 

query optimizing please

abirhasan
Master User

Hello programmers,
First of all Im beginner got no experience on this, so please step by step on me.

I have an application running on a VPS with 1GB RAM, the website become so slow and even unreachable when receiving a huge among of traffics (about 500visitors online or more according to Google anaytics) actually these are not real visitors to my website these are clients who are viewing my application widget collecting visitors informations,
tried optimizing the httpd conf and my.inf with no help, and after checking the slow log I found that the bellow queries are the cause:

"UPDATE LOW_PRIORITY `visitors` AS t1, (SELECT gl.`latitude` AS `lat`,gl.`longitude` AS 
`lng`,gl.`country_name` as `country_name`,gl.`city` as `city` FROM `geolitecity_locations` AS gl WHERE gl.`locId` = (SELECT 
`locId` FROM `geolitecity_blocks` WHERE $visitor_id BETWEEN `geolitecity_blocks`.`startIpNum` AND 
`geolitecity_blocks`.`endIpNum`)) AS t2 SET t1.lat = t2.lat, t1.lng = t2.`lng`, t1.city = t2.city, t1.country = 
t2.country_name WHERE t1.ip = $visitor_id";

"UPDATE `stats_dynamic` SET `time_end` = UNIX_TIMESTAMP() WHERE `user_code` = '$user_code' AND `href` = '$href' AND `time_start` = " . $update_data['time_start'] . " AND `visitor_id` = $visitor_id";

"INSERT INTO `stats_dynamic` (`user_code`, `href`, `visitor_id`, `time_start`,`time_end`) VALUES ('$user_code', '$href', $visitor_id, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()+" . TIME_INTERVAL . ")";

 I don't know if the database is using index or even if I must uses index on the table cause I read somewhere its bad to use it on some cases.

Some DB stats:
max. concurrent connections 91
Engine used InnoDB and MYISAM
If you want I can put my.inf and httpd.conf but I thing these are not the problem.

 

Thanks 

1 REPLY 1

Sogo7
Grand Master

Oh that's an easy SQL question to answer because it has nothing to do with databases.

 

 

A better question to ask in any webmaster forum would be...

 

"Are posts with concealed images a good way to boost a websites SEO"

 

<img border="0" src="http://imagicon.info/cat/12-1/text-smiley.png">

 

or how about...

 

"Is it against the law to give users a cookie without their informed consent?"

Lovelogic.net UK Jobs Scanner