Click here to Skip to main content
15,897,273 members
Home / Discussions / Database
   

Database

 
GeneralRe: About + operator for string Pin
Ashfield26-Sep-08 2:18
Ashfield26-Sep-08 2:18 
GeneralRe: About + operator for string Pin
TALHAKOSEN26-Sep-08 2:22
TALHAKOSEN26-Sep-08 2:22 
GeneralRe: About + operator for string Pin
Ashfield26-Sep-08 3:18
Ashfield26-Sep-08 3:18 
Generalone more )) pls variable doesnt increase ??? Pin
TALHAKOSEN26-Sep-08 3:56
TALHAKOSEN26-Sep-08 3:56 
GeneralRe: one more )) pls variable doesnt increase ??? Pin
Ashfield26-Sep-08 4:25
Ashfield26-Sep-08 4:25 
GeneralRe: one more )) pls variable doesnt increase ??? Pin
TALHAKOSEN26-Sep-08 4:38
TALHAKOSEN26-Sep-08 4:38 
GeneralRe: one more )) pls variable doesnt increase ??? Pin
Ashfield26-Sep-08 8:18
Ashfield26-Sep-08 8:18 
QuestionSlow Random Products Pin
Heylow26-Sep-08 1:27
Heylow26-Sep-08 1:27 
Hi
QUESTION:
Why is the code running so slow and what can I do to improve it?

THE CODE:
$currentTable = "SS_products";
$q1 = db_query("SELECT FLOOR(RAND() * COUNT(*)) AS rand_row FROM ".
$currentTable) or die (db_error());

$row1 = db_fetch_row($q1);
$q2 = db_query("SELECT categoryID, name, default_picture FROM ".
$currentTable." WHERE categoryID=7 Limit $row1[0], 1") or die (db_error());


Background Infomation on the Code:
I have a website where I use a shopping cart system called ShopScript Premium. This system works more then fine with my current webhost BlueHost. But a problem arises when I add customized the code.

I have added to the website home page that every time the browser is refreshed 10 new random products will be the customers. The ShopScript system only offers products which are to be changed by the administrator manually. When the code for the random product is executed the website runs considerably slower then without the random products, although sometimes and does run with no problems and fast speed for a minute or so. Even if the user is using the other pages the website is still slow. I suspect this has to do with the fact that the ShopScript system uses a smarty engine, although that does not fully explain why.

In my database the table called has 1373 rows. I use the code above to randomly select one of the rows to be viewed on the website. According to my log on mySQL slow queries, the above mentioned code, is the source of the problems. The log states that the code uses 2 to 4 seconds query time. My webhost does not allow any single process taking more than 30 CPU seconds to run or if the total processes take more than 40 CPU seconds in any 60 second window to avoid server lockups. Such an event triggers a CPU Quota/Suspension Error, where my website is accessable for 5 to 10 minutes. This is a big problem as I lose customers this way.

On before hand
Thank you for your help

AnswerRe: Slow Random Products Pin
SimulationofSai26-Sep-08 1:34
SimulationofSai26-Sep-08 1:34 
AnswerRe: Slow Random Products Pin
Ashfield26-Sep-08 1:58
Ashfield26-Sep-08 1:58 
QuestionAbout reporting Pin
TALHAKOSEN25-Sep-08 22:49
TALHAKOSEN25-Sep-08 22:49 
AnswerRe: About reporting Pin
HemJoshi25-Sep-08 23:10
HemJoshi25-Sep-08 23:10 
GeneralRe: About reporting Pin
TALHAKOSEN25-Sep-08 23:16
TALHAKOSEN25-Sep-08 23:16 
QuestionHow can i change name of variable ? Pin
TALHAKOSEN25-Sep-08 22:30
TALHAKOSEN25-Sep-08 22:30 
AnswerRe: How can i change name of variable ? Pin
Ashfield25-Sep-08 22:40
Ashfield25-Sep-08 22:40 
AnswerRe: How can i change name of variable ? Pin
Wendelius26-Sep-08 6:48
mentorWendelius26-Sep-08 6:48 
Questionmysql and Ado.net Pin
Christopher Clarke25-Sep-08 15:42
Christopher Clarke25-Sep-08 15:42 
AnswerRe: mysql and Ado.net Pin
John_Adams25-Sep-08 20:50
John_Adams25-Sep-08 20:50 
QuestionConverting datetime format to only time format in one column Pin
notes4we25-Sep-08 9:24
notes4we25-Sep-08 9:24 
AnswerRe: Converting datetime format to only time format in one column Pin
NeverHeardOfMe25-Sep-08 10:07
NeverHeardOfMe25-Sep-08 10:07 
GeneralRe: Converting datetime format to only time format in one column Pin
notes4we26-Sep-08 3:44
notes4we26-Sep-08 3:44 
Question[Message Deleted] Pin
Christopher Clarke25-Sep-08 9:09
Christopher Clarke25-Sep-08 9:09 
AnswerRe: MySql or Ado.net Pin
NeverHeardOfMe25-Sep-08 9:51
NeverHeardOfMe25-Sep-08 9:51 
QuestionOracle ODBC Driver (version 10+) Pin
Xiangyang Liu 刘向阳25-Sep-08 7:14
Xiangyang Liu 刘向阳25-Sep-08 7:14 
QuestionReading data from OPC packets, convert and sending to ODBC program Pin
CarstenK litgaard Holm25-Sep-08 5:11
CarstenK litgaard Holm25-Sep-08 5:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.