views:

114

answers:

2

I have been starting to write some reasonably large and or confusing MySQL queries in PHP. I am trying to find a balance between verbosity and performance... If performance has anything to do with it or not is my question.

It being white space and MySQL comments inside of my queries. It would make sense to me that PHP would filter the queries unessential white space and maybe even mysql comments inside of the query before it is sent but i'm not sure...

SO, SIMPLEY PUT:

Will white space and comments go over the wire to from PHP to MySQL if so does it really even matter in terms of performance?

I'm not looking for hard performance benchmarks or anything... but in general would like to know.

Thanks in advance :)

+6  A: 

Yes, they will go over the wire although I don't know enough about mysql to tell you whether they would affect performance. I'd guess that if you have to of the same queries with different comments they would slightly affect query parsing time and mysql should be capable of optimizing for a repeated query. Though, I'd suspect that usually the transport delay between the web and database server and the size of the results will completely dwarf the queries and any performance issues with parsing queries and without real hard numbers you won't really know. Personally, it wouldn't be something I would worry too much about.

skirmish
+3  A: 

I support skirmish's comment. There are dozens of other places you can get much bigger bang for the buck in terms of performance optimization. Compressing the size of the SQL query is not high on this list.

Bill Karwin