You are here: Re: Optimization of mySQL to XML output... « PHP Programming Language « IT news, forums, messages
Re: Optimization of mySQL to XML output...

Posted by shimmyshack on 10/24/07 19:14

On Oct 24, 5:51 pm, jfi...@vintara.com wrote:
> I'm trying to print out a table of mySQL data as XML. However, the
> performance I'm getting is REALY bad. Adding the header("Content-Type:
> $mime;charset=$charset"); statement triples the load time of the data
> for example. Can someone with more php experience then I look this
> over and tell me that I'm stupid and doing it wrong?
>
> define( "DATABASE_SERVER", "localhost" );
> define( "DATABASE_USERNAME", "root" );
> define( "DATABASE_PASSWORD", "" );
> define( "DATABASE_NAME", "mydatabase" );
>
> $method=$_GET['method'];
>
> //connect to the database
> $mysql = mysql_connect(DATABASE_SERVER, DATABASE_USERNAME,
> DATABASE_PASSWORD);
> mysql_select_db( DATABASE_NAME );
>
> function getDataNames()
> {
> $Query = "SELECT * from `My Data`";
> $Result = mysql_query( $Query );
> //$charset = "iso-8859-1";
> //$mime = "text/xml";
> //header("Content-Type: $mime;charset=$charset");
> print ("<response>");
> while ( $DataName = mysql_fetch_object( $Result ) )
> {
> //$Return .= "<data><name>".$DataName->DataName."</
> name><iocode>".$DataName->IOCode."</iocode><coicop>".$DataName->COICOP."</coicop></data>";
>
> print ("<data>");
> print ("<name>".$DataName->DataName."</name>");
> print ("<code1>".$DataName->code1."</code1>");
> print ("<code2>".$DataName->code2."</code2>");
> print ("<code3>".$DataName->IOComName."</code3>");
> print ("<code4>42</code4>");
> print ("<code5>".$DataName->high_total_IOComName."</code5>");
> print ("<code6>".$DataName->high_prod_IOComName."</code6>");
> print ("<code7>".$DataName->high_whole_IOComName."</code7>");
> print ("<code8>".$DataName->high_whole_IOComName."</code8>");
> print ("<code9>".$DataName->high_whole_IOComName."</code9>");
> print ("</data>");
> }
> print ("</response>");
> mysql_free_result( $Result );
>
> }

tha fact that adding a header triples the load time suggests to me
that what you are annoyed about is the rendering time, rather than the
script time.
(I havent looked at the script to optimise it)
I suggest you goto the command line and simply save the file
grab wget for windows
http://www.google.com/search?hl=en&q=wget1.6+windows&btnG=Search
and on the command line, issue
wget http://example.com/script.php
and see how fast it is (the time will be shown)

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация