Too fast web page for mysql database

This is a discussion on Too fast web page for mysql database within the MySQL Database forums, part of the Database Forums category; Hello! I am not an admin of my database, but I care of this database. I have a web page ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-24-2007
MZ
 
Posts: n/a
Default Too fast web page for mysql database

Hello!

I am not an admin of my database, but I care of this database.
I have a web page which inserts records into the mysql database about history of
just viewed banners.
I have written a script which let my page display banners in order. Every
reloading web page should make different banner display. That`s why I store
history of every banner of every section and I display banner which were viewed
the oldest time ago.
I don`t know why my mysql database sometimes don`t insert data into the database
and that`s why my web page shows every time the same banner. If I leave my
database for a few minutes and then reload the page, there are records added
into the database.

In the past I took care of MS Access databases and there was something as
compacting. What should I do make my mysql database response quicker? How can I
compact my database and should I do this during working hours when many people
use my web page? Is it needed to do it i.e. at night where fewer people look
into my web page?

Please help me, I really apprieciete your efforts.
Thank you
Marcin

Reply With Quote
  #2 (permalink)  
Old 10-25-2007
K.
 
Posts: n/a
Default Re: Too fast web page for mysql database


Użytkownik "MZ" <marcinzmyslowski@poczta.onet.pl> napisał w wiadomości
news:ffo21o$m9d$1@news.onet.pl...
> Hello!
>
> I am not an admin of my database, but I care of this database.
> I have a web page which inserts records into the mysql database about
> history of just viewed banners.
> I have written a script which let my page display banners in order. Every
> reloading web page should make different banner display. That`s why I
> store history of every banner of every section and I display banner which
> were viewed the oldest time ago.
> I don`t know why my mysql database sometimes don`t insert data into the
> database and that`s why my web page shows every time the same banner. If I
> leave my database for a few minutes and then reload the page, there are
> records added into the database.
>
> In the past I took care of MS Access databases and there was something as
> compacting. What should I do make my mysql database response quicker? How
> can I compact my database and should I do this during working hours when
> many people use my web page? Is it needed to do it i.e. at night where
> fewer people look into my web page?
>
> Please help me, I really apprieciete your efforts.
> Thank you
> Marcin


OPTIMIZE TABLE name_table


Reply With Quote
  #3 (permalink)  
Old 10-25-2007
Captain Paralytic
 
Posts: n/a
Default Re: Too fast web page for mysql database

On 24 Oct, 19:14, "MZ" <marcinzmyslow...@poczta.onet.pl> wrote:
> Hello!
>
> I am not an admin of my database, but I care of this database.
> I have a web page which inserts records into the mysql database about history of
> just viewed banners.
> I have written a script which let my page display banners in order. Every
> reloading web page should make different banner display. That`s why I store
> history of every banner of every section and I display banner which were viewed
> the oldest time ago.
> I don`t know why my mysql database sometimes don`t insert data into the database
> and that`s why my web page shows every time the same banner. If I leave my
> database for a few minutes and then reload the page, there are records added
> into the database.
>
> In the past I took care of MS Access databases and there was something as
> compacting. What should I do make my mysql database response quicker? How can I
> compact my database and should I do this during working hours when many people
> use my web page? Is it needed to do it i.e. at night where fewer people look
> into my web page?
>
> Please help me, I really apprieciete your efforts.
> Thank you
> Marcin


Are you testing the response from the statements you are using to
update the database?

Reply With Quote
  #4 (permalink)  
Old 10-25-2007
K.
 
Posts: n/a
Default Re: Too fast web page for mysql database

> Are you testing the response from the statements you are using to
> update the database?
>


No I am testing the statements I am using to insert data into the database.

M.


Reply With Quote
  #5 (permalink)  
Old 10-25-2007
Captain Paralytic
 
Posts: n/a
Default Re: Too fast web page for mysql database

On 25 Oct, 09:47, "K." <halinaciern...@poczta.onet.pl> wrote:
> > Are you testing the response from the statements you are using to
> > update the database?

>
> No I am testing the statements I am using to insert data into the database.
>
> M.


I mean in your code, to you check the return from the statements used
to update the database? Then you will see if there was a problem with
the update!

Reply With Quote
  #6 (permalink)  
Old 10-25-2007
K.
 
Posts: n/a
Default Re: Too fast web page for mysql database


Uzytkownik "Captain Paralytic" <paul_lautman@yahoo.com> napisal w wiadomosci
news:1193302856.982034.302570@y42g2000hsy.googlegr oups.com...
> On 25 Oct, 09:47, "K." <halinaciern...@poczta.onet.pl> wrote:
>> > Are you testing the response from the statements you are using to
>> > update the database?

>>
>> No I am testing the statements I am using to insert data into the
>> database.
>>
>> M.

>
> I mean in your code, to you check the return from the statements used
> to update the database? Then you will see if there was a problem with
> the update!
>


I have such code. I have made a mistake, I make update and insert, but I am
interested in the table banner_view_history,
where I store data about banners` views. My function returns nothing. I do
"OPTIMIZE TABLE banner_view_history" and
"OPTIMIZE TABLE banner_items" and I think that problem disappeared. But I am
not sure for 100%.

function UpdateBannerCount($id) {
$this->_clearDBError();
if(!$this->_connect()) {
return false;
}
$sql = "SELECT id_banner_locations FROM
".$this->dbconfig["prefix"]."banner_items WHERE id_banner_items=".$id;

$resultat = @mysql_query($sql);
$assoc = @mysql_fetch_assoc($resultat);

$this->query = "UPDATE ".$this->dbconfig["prefix"]."banner_items bi SET
banner_view_count = banner_view_count+1 WHERE id_banner_items=".$id;
$this->result = @mysql_query($this->query);

$data = array(
"referer" => isset($_SERVER["HTTP_REFERER"])?$_SERVER["HTTP_REFERER"]:"",
"useragent" =>
isset($_SERVER["HTTP_USER_AGENT"])?$_SERVER["HTTP_USER_AGENT"]:"",
"cookies_name"
=>(isset($_COOKIE['test_cookie'])?$_COOKIE['test_cookie']:$_SESSION["test_cookie_session"]),
"view_date" => date("Y-m-d H:i:s"),
"id_banner_locations"=>$assoc["id_banner_locations"],
"id_banner_items" => $id
);
$this->addElement($this->dbconfig["prefix"]."banner_view_history", $data);

}

Marcin


Reply With Quote
  #7 (permalink)  
Old 10-25-2007
Captain Paralytic
 
Posts: n/a
Default Re: Too fast web page for mysql database

On 25 Oct, 10:50, "K." <halinaciern...@poczta.onet.pl> wrote:
> Uzytkownik "Captain Paralytic" <paul_laut...@yahoo.com> napisal w wiadomoscinews:1193302856.982034.302570@y42g2000hs y.googlegroups.com...
>
> > On 25 Oct, 09:47, "K." <halinaciern...@poczta.onet.pl> wrote:
> >> > Are you testing the response from the statements you are using to
> >> > update the database?

>
> >> No I am testing the statements I am using to insert data into the
> >> database.

>
> >> M.

>
> > I mean in your code, to you check the return from the statements used
> > to update the database? Then you will see if there was a problem with
> > the update!

>
> I have such code. I have made a mistake, I make update and insert, but I am
> interested in the table banner_view_history,
> where I store data about banners` views. My function returns nothing. I do
> "OPTIMIZE TABLE banner_view_history" and
> "OPTIMIZE TABLE banner_items" and I think that problem disappeared. But Iam
> not sure for 100%.
>
> function UpdateBannerCount($id) {
> $this->_clearDBError();
> if(!$this->_connect()) {
> return false;
> }
> $sql = "SELECT id_banner_locations FROM
> ".$this->dbconfig["prefix"]."banner_items WHERE id_banner_items=".$id;
>
> $resultat = @mysql_query($sql);
> $assoc = @mysql_fetch_assoc($resultat);
>
> $this->query = "UPDATE ".$this->dbconfig["prefix"]."banner_items bi SET
> banner_view_count = banner_view_count+1 WHERE id_banner_items=".$id;
> $this->result = @mysql_query($this->query);
>
> $data = array(
> "referer" => isset($_SERVER["HTTP_REFERER"])?$_SERVER["HTTP_REFERER"]:"",
> "useragent" =>
> isset($_SERVER["HTTP_USER_AGENT"])?$_SERVER["HTTP_USER_AGENT"]:"",
> "cookies_name"
> =>(isset($_COOKIE['test_cookie'])?$_COOKIE['test_cookie']:$_SESSION["test_c*ookie_session"]),
> "view_date" => date("Y-m-d H:i:s"),
> "id_banner_locations"=>$assoc["id_banner_locations"],
> "id_banner_items" => $id
> );
> $this->addElement($this->dbconfig["prefix"]."banner_view_history", $data);
>
> }
>
> Marcin


What do you mean "my function returns nothing"?

I cannot see anywhere in this code where you check for the success of
any of your database updates or an error messages returned.

Reply With Quote
  #8 (permalink)  
Old 10-25-2007
K.
 
Posts: n/a
Default Re: Too fast web page for mysql database


Uzytkownik "Captain Paralytic" <paul_lautman@yahoo.com> napisal w wiadomosci
news:1193306848.856496.56120@57g2000hsv.googlegrou ps.com...
On 25 Oct, 10:50, "K." <halinaciern...@poczta.onet.pl> wrote:
> Uzytkownik "Captain Paralytic" <paul_laut...@yahoo.com> napisal w
> wiadomoscinews:1193302856.982034.302570@y42g2000hs y.googlegroups.com...
>
> > On 25 Oct, 09:47, "K." <halinaciern...@poczta.onet.pl> wrote:
> >> > Are you testing the response from the statements you are using to
> >> > update the database?

>
> >> No I am testing the statements I am using to insert data into the
> >> database.

>
> >> M.

>
> > I mean in your code, to you check the return from the statements used
> > to update the database? Then you will see if there was a problem with
> > the update!

>
> I have such code. I have made a mistake, I make update and insert, but I
> am
> interested in the table banner_view_history,
> where I store data about banners` views. My function returns nothing. I do
> "OPTIMIZE TABLE banner_view_history" and
> "OPTIMIZE TABLE banner_items" and I think that problem disappeared. But I
> am
> not sure for 100%.
>
> function UpdateBannerCount($id) {
> $this->_clearDBError();
> if(!$this->_connect()) {
> return false;
> }
> $sql = "SELECT id_banner_locations FROM
> ".$this->dbconfig["prefix"]."banner_items WHERE id_banner_items=".$id;
>
> $resultat = @mysql_query($sql);
> $assoc = @mysql_fetch_assoc($resultat);
>
> $this->query = "UPDATE ".$this->dbconfig["prefix"]."banner_items bi SET
> banner_view_count = banner_view_count+1 WHERE id_banner_items=".$id;
> $this->result = @mysql_query($this->query);
>
> $data = array(
> "referer" =>
> isset($_SERVER["HTTP_REFERER"])?$_SERVER["HTTP_REFERER"]:"",
> "useragent" =>
> isset($_SERVER["HTTP_USER_AGENT"])?$_SERVER["HTTP_USER_AGENT"]:"",
> "cookies_name"
> =>(isset($_COOKIE['test_cookie'])?$_COOKIE['test_cookie']:$_SESSION["test_c*ookie_session"]),
> "view_date" => date("Y-m-d H:i:s"),
> "id_banner_locations"=>$assoc["id_banner_locations"],
> "id_banner_items" => $id
> );
> $this->addElement($this->dbconfig["prefix"]."banner_view_history",
> $data);
>
> }
>
> Marcin


What do you mean "my function returns nothing"?

I cannot see anywhere in this code where you check for the success of
any of your database updates or an error messages returned.

-----------------------------------
I mean that I don`t have such code

function name_function
{
//operations on database
.....
return $result;
}

by writing "my function returns nothing".

I don`t want to return anything because I use javascript SWFObject class to
display flash banners and I call URL i.e. banner.php?id=22.
banner.php file contains two things:
1) the above function update and insert into the database - to increase the
number of banner (id=22) views
and add visit trace into the banner_view_history table.
2) return needed data about the flash banner to make it display on the page

<script type="text/javascript">
// <![CDATA[
var so = new SWFObject("banner.php?id=22", "fl_top22_f", "770", "100",
"7", "#ffffff");
so.addVariable("quality", "high");
so.addVariable("clickTag", "bannerclick.php%3Fid%3D22");
so.write("fl_top"+22);
// ]]>
</script>

Marcin


Reply With Quote
  #9 (permalink)  
Old 10-25-2007
Captain Paralytic
 
Posts: n/a
Default Re: Too fast web page for mysql database

On 25 Oct, 12:45, "K." <halinaciern...@poczta.onet.pl> wrote:
> Uzytkownik "Captain Paralytic" <paul_laut...@yahoo.com> napisal w wiadomoscinews:1193306848.856496.56120@57g2000hsv. googlegroups.com...
> On 25 Oct, 10:50, "K." <halinaciern...@poczta.onet.pl> wrote:
>
>
>
>
>
> > Uzytkownik "Captain Paralytic" <paul_laut...@yahoo.com> napisal w
> > wiadomoscinews:1193302856.982034.302570@y42g2000hs y.googlegroups.com...

>
> > > On 25 Oct, 09:47, "K." <halinaciern...@poczta.onet.pl> wrote:
> > >> > Are you testing the response from the statements you are using to
> > >> > update the database?

>
> > >> No I am testing the statements I am using to insert data into the
> > >> database.

>
> > >> M.

>
> > > I mean in your code, to you check the return from the statements used
> > > to update the database? Then you will see if there was a problem with
> > > the update!

>
> > I have such code. I have made a mistake, I make update and insert, but I
> > am
> > interested in the table banner_view_history,
> > where I store data about banners` views. My function returns nothing. Ido
> > "OPTIMIZE TABLE banner_view_history" and
> > "OPTIMIZE TABLE banner_items" and I think that problem disappeared. ButI
> > am
> > not sure for 100%.

>
> > function UpdateBannerCount($id) {
> > $this->_clearDBError();
> > if(!$this->_connect()) {
> > return false;
> > }
> > $sql = "SELECT id_banner_locations FROM
> > ".$this->dbconfig["prefix"]."banner_items WHERE id_banner_items=".$id;

>
> > $resultat = @mysql_query($sql);
> > $assoc = @mysql_fetch_assoc($resultat);

>
> > $this->query = "UPDATE ".$this->dbconfig["prefix"]."banner_items biSET
> > banner_view_count = banner_view_count+1 WHERE id_banner_items=".$id;
> > $this->result = @mysql_query($this->query);

>
> > $data = array(
> > "referer" =>
> > isset($_SERVER["HTTP_REFERER"])?$_SERVER["HTTP_REFERER"]:"",
> > "useragent" =>
> > isset($_SERVER["HTTP_USER_AGENT"])?$_SERVER["HTTP_USER_AGENT"]:"",
> > "cookies_name"
> > =>(isset($_COOKIE['test_cookie'])?$_COOKIE['test_cookie']:$_SESSION["test_c**ookie_session"]),
> > "view_date" => date("Y-m-d H:i:s"),
> > "id_banner_locations"=>$assoc["id_banner_locations"],
> > "id_banner_items" => $id
> > );
> > $this->addElement($this->dbconfig["prefix"]."banner_view_history",
> > $data);

>
> > }

>
> > Marcin

>
> What do you mean "my function returns nothing"?
>
> I cannot see anywhere in this code where you check for the success of
> any of your database updates or an error messages returned.
>
> -----------------------------------
> I mean that I don`t have such code
>
> function name_function
> {
> //operations on database
> ....
> return $result;
>
> }
>
> by writing "my function returns nothing".
>
> I don`t want to return anything because I use javascript SWFObject classto
> display flash banners and I call URL i.e. banner.php?id=22.
> banner.php file contains two things:
> 1) the above function update and insert into the database - to increase the
> number of banner (id=22) views
> and add visit trace into the banner_view_history table.
> 2) return needed data about the flash banner to make it display on the page
>
> <script type="text/javascript">
> // <![CDATA[
> var so = new SWFObject("banner.php?id=22", "fl_top22_f", "770", "100",
> "7", "#ffffff");
> so.addVariable("quality", "high");
> so.addVariable("clickTag", "bannerclick.php%3Fid%3D22");
> so.write("fl_top"+22);
> // ]]>
> </script>
>
> Marcin- Hide quoted text -
>
> - Show quoted text -


So write any errors to a log file. Then you can see what's happening.
You don't have to output them to the browser.

Reply With Quote
  #10 (permalink)  
Old 10-25-2007
K.
 
Posts: n/a
Default Re: Too fast web page for mysql database

> <script type="text/javascript">
> // <![CDATA[
> var so = new SWFObject("banner.php?id=22", "fl_top22_f",
> "770", "100",
> "7", "#ffffff");
> so.addVariable("quality", "high");
> so.addVariable("clickTag", "bannerclick.php%3Fid%3D22");
> so.write("fl_top"+22);
> // ]]>
> </script>
>
> Marcin- Hide quoted text -
>
> - Show quoted text -


So write any errors to a log file. Then you can see what's happening.
You don't have to output them to the browser.


OK but what about the speed of inserts into database. I do not think that`s
the problem of
errors while inserting or updating the data, because data during every
reloading the page
are the same and the only difference is that view_date is changing.

M.


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 08:33 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0