List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:March 4 2003 3:28am
Subject:Re: Querying for performance...
View as plain text  
At 13:19 -0600 3/31/03, Jonathan Villa wrote:
>All,
>
>I have been writing my applications using PHP/MySQL for about a year and
>a half now.  During this time and up to now, there hasn't been anything
>wrong with my apps; however, I need to know if what I am doing is the
>best route for optimal performance.
>
>So I ask these questions:
>
>1.	How many queries can MySQL handle?
>	For example, one of my functions does this:
>	While (I am selecting some data)
>	{
>		while (use one of the results as an element to query a
>different table)
>		{
>		echo the results formatted in html
>	}
>	}
>       I'm sure that I could be using a join, but this is an example.

You're probably thinking that you're issuing multiple queries simultaneously
when you're doing that, but unless you're playing tricks with buffering,
you're not.  By the time you get to the while loop ("selecting some data"),
the first query has already been processed completely and the entire result
set has been received on the client end.  The server's done with it by
the time you start issuing queries inside the loop.

>
>2.	I am under the impression that a char is 'a character', but I
>have read and think I have seen it used with more than one character.
>For example, char (5).  If this is correct, how many values can char
>hold?

CHAR(5) means a 5-byte char column.  That is, a column that can hold
up to 5 bytes of character data.  For single-byte character sets (the
usual case), that means 5 characters.

>3.	Is it true that varchar appends spaces to the value if it's not
>all set?  For example, if a varchar is set to 255 and my value is really
>only 245, then 10 whitespaces will be appended to the original value.

No, this is false for VARCHAR.  It's true for CHAR in the sense that for
a CHAR(255) column, 255 bytes will always be store.

VARCHAR only stores as many bytes as needed, after trailing spaces, if
any, are removed.

>
>-Jonathan

Thread
Querying for performance...Jonathan Villa3 Mar
  • Re: Querying for performance...Paul DuBois4 Mar
    • RE: Querying for performance...Jonathan Villa4 Mar