Jump to content

Recommended Posts

Well I have an include file that pulls a num_rows variable from the database.

I have this page included in a few different pages throughout the site - however, on just one page, it runs very slow.

 

here's the script:

<?php

$foxridge[8] = 3;
$foxridge[6] = 6;

$alpine[8] = 10;
$alpine[6] = 10;

$valley[8] = 5;
$valley[6] = 1;

$inn[2] = 10;
$inn[4] = 89;

$wildflower[2] = 23;
$wildflower[4] = 32;
$wildflower[6] = 20;

$snowpine[2] = 4;
$snowpine[4] = 18;
$snowpine[6] = 30;
$snowpine[8] = 15;

foreach($foxridge as $k=>$v){
$sql = "SELECT b_id FROM breakaway WHERE b_location='foxridge' AND b_numRoommates='".$k."'";
if(mysql_num_rows(mysql_query($sql)) >= $v)
	$foxridge[$k] = false;
	//echo "<br>Foxridge: ".$k." - ".$v." - ".mysql_num_rows(mysql_query($sql));
	echo date("H:i:s");
	echo "<br>";
}

foreach($alpine as $k=>$v){
$sql = "SELECT b_id FROM breakaway WHERE b_location='alpinemeadow' AND b_numRoommates='".$k."'";
if(mysql_num_rows(mysql_query($sql)) >= $v)
	$alpine[$k] = false;
	//echo "<br>Alpine: ".$k." - ".$v." - ".mysql_num_rows(mysql_query($sql));
	echo date("H:i:s");
	echo "<br>";
}
foreach($valley as $k=>$v){
$sql = "SELECT b_id FROM breakaway WHERE b_location='valleyvillage' AND b_numRoommates='".$k."'";
if(mysql_num_rows(mysql_query($sql)) >= $v)
	$valley[$k] = false;
	//echo "<br>Valley: ".$k." - ".$v." - ".mysql_num_rows(mysql_query($sql));
	echo date("H:i:s");
	echo "<br>";
}
foreach($inn as $k=>$v){
$sql = "SELECT b_id FROM breakaway WHERE b_location='inn' AND b_numRoommates='".$k."'";
if(mysql_num_rows(mysql_query($sql)) >= $v)
	$inn[$k] = false;
	//echo "<br>The Inn: ".$k." - ".$v." - ".mysql_num_rows(mysql_query($sql));
	echo date("H:i:s");
	echo "<br>";
}
foreach($wildflower as $k=>$v){
$sql = "SELECT b_id FROM breakaway WHERE b_location='wildflower' AND b_numRoommates='".$k."'";
if(mysql_num_rows(mysql_query($sql)) >= $v)
	$wildflower[$k] = false;
	//echo "<br>Wildflower: ".$k." - ".$v." - ".mysql_num_rows(mysql_query($sql));
	echo date("H:i:s");
	echo "<br>";
}
foreach($snowpine as $k=>$v){
$sql = "SELECT b_id FROM breakaway WHERE b_location='snowpine' AND b_numRoommates='".$k."'";
if(mysql_num_rows(mysql_query($sql)) >= $v)
	$snowpine[$k] = false;
	//echo "<br>Snowpine: ".$k." - ".$v." - ".mysql_num_rows(mysql_query($sql));
	echo date("H:i:s");
	echo "<br>";
}

$twos = true;
$fours = true;
$sixs = true;
$eights = true;

if(($snowpine[2]==false)&&($wildflower[2]==false)&&($inn[2]==false)){
$twos = false;
}
if(($snowpine[4]==false)&&($wildflower[4]==false)&&($inn[4]==false)){
$fours = false;
}
if(($snowpine[6]==false)&&($wildflower[6]==false)&&($valley[6]==false)&&($foxridge[6]==false)&&($alpine[6]==false)){
$sixs = false;
}
if(($snowpine[8]==false)&&($valley[8]==false)&&($foxridge[8]==false)&&($alpine[8]==false)){
$eights = false;
}

?>

 

now it will output the timestamp of each query, so I can debug.

on one page it looked like this:

09:53:32

09:53:32

09:53:32

09:53:32

09:53:32

09:53:32

09:53:32

09:53:32

09:53:32

09:53:32

09:53:32

09:53:32

09:53:32

09:53:32

09:53:32

 

on the page in question, it took about 1 second per query:

09:56:14

09:56:14

09:56:15

09:56:16

09:56:17

09:56:19

09:56:20

09:56:21

09:56:22

09:56:23

09:56:24

09:56:25

09:56:26

09:56:27

09:56:28

 

as you can see this dramitically increases page load time (this is for older women, they will think the world ended if it doesn't load in 5 seconds and keep clicking  :facewall::shrug:)

 

The first page, which loads the include very fast start out like this (checkRooms.php is the include in question)

 

<?php
session_start();
session_destroy();
session_start();
include('db.php');
require('checkRooms.php');
?>

 

the second page is VERY simalir:

<?php
session_start();
include('checkRooms.php');
?>

 

 

why would this code load sooooooooo slow on only this page? this makes no sense to me. the worst part is everything loaded nice and fast until this morning  :shrug:

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.