From: Ondrej J. <ne...@po...> - 2003-03-12 01:19:49
|
> >>double quotes wrap onto the next line so we tend to do this all as > >>one string instead of having to put the . and the "" on each line. > > Actually using this approach final query contains a lot of spaces, > > which have to be removed by RDBMS SQL parser. I hope you realize > > this. > This is true, and no, I had never considered it. Do you think the > extra parsing time has any non-negligable effect on the total time as > compared to the query processing time? I would expect it would > increase the query time by a thousandth (or a millionth?) of a second > which isn't going to amount to anything compared to the time to > execute the query, transfer the data to php, parse the code, analyze > the data, send the web page to the browser... but I'd be very > interested to hear if you think it actually adds any significant > amount of time. Do you have any stats? Long time ago, when I worked as Perl CGI developer, I was curious about this. I leave one evening in work and performed serveral tests on slow machine regarding this issue. However, no increase in query parsing time were noticed (RDBMS: MySQL 4.23.xx, machine: Pentium 120Mhz). The important matter is, that when you debug queries using MySQL server log feature, they look strange. We are using Mantis in combination with another applications (phpMyEzin, phpBB, etc.) and the difference is noticeable: 4 Query UPDATE ezin_counts_temp SET timestamp = UNIX_TIMESTAMP(SYSDATE()) WHERE ip = "192.168.1.1" AND type_id = "s501" 4 Query SELECT u.username FROM phpbb2_sessions AS s, phpbb2_users AS u WHERE s.sess ion_id = "" AND u.user_id = s.session_user_id [... ...] 10 Query SELECT id FROM mantis_user_table WHERE cookie_string='' 10 Query SELECT id, cookie_string FROM mantis_user_table WHERE username = "anonymous" 10 Query SELECT access_level FROM mantis_project_user_list_table WHERE user_id='2' AND project_id='5' And the last but not the least, as I was talking about no load increase for RDBMS server, there should be taken into consideration PHP parser engine load. It is for discussion what is more bad - if the long string maintainance or the short strings concatenation. I personally use approach with following style: $query = sprintf('INSERT INTO %s' .' (id,parent,article_id,author,email,homepage,subject,message,datetime,ip)' .' VALUES (0,"%s","%s","%s","%s","%s","%s","%s",SYSDATE(),"%s")', $ezin_sys['db']['tables']['messages'], $data['parent'], $data['article_id'], $data['author'], $data['email'], $data['homepage'], $data['subject'], $data['message'], $data['ip']); I do not think that Mantis' one is bad. I just wanted to point you on fact, that spaces are there. -- _/| Ondrej Jombik - ne...@ph... - http://www.nepto.sk - OJ812-RIPE <_ \ Platon SDG - open source software development - http://platon.sk `\| Ako sa do hory vola, tak sa zhori traktor! (c) 1999 Rattkin/MFF '` |