Forum Moderators: coopster

Message Too Old, No Replies

Two Queries

mysql - how much will this slow things down?

         

wener

7:49 am on Jul 21, 2005 (gmt 0)

10+ Year Member



I will query two mysql tables using two differnt query strings in one php file.(One query for category information and one for product information). Is it normal or not good to query more than once? Since it's my first php site, I am not sure about that. Thank you for your input in advance.

omoutop

7:57 am on Jul 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



There is no problemo with that...u can even query different tables from different databases in one script if u want ;)

example of what u want:
$query2 = "select * from Distances where HotelID ='$ID'";
$result2 = mysql_query($query2);
while ($row2=mysql_fetch_assoc($result2))
{
$Airport = $row2['Airport'];
$Port = $row2['Port'];
$Center = $row2['Center'];
$Beach = $row2['Beach'];
$FlagDistance = $row2['FlagDistance'];

};
$query3 = "select * from Hfacilities where HotelID ='$ID'";
$result3 = mysql_query($query3);
while ($row3=mysql_fetch_assoc($result3))
{
$HFD = $row3['FD'];
$HFN = $row3['FN'];
$HRE = $row3['RE'];
$HPO = $row3['PO'];
$HIN = $row3['NN'];
$HST = $row3['ST'];
$HAC = $row3['AC'];
$HBR = $row3['BR'];
$HBA = $row3['BA'];
$HGA = $row3['GA'];
$HLS = $row3['LS'];
$HPA = $row3['PA'];
$FlagHFacilities = $row3['Flag'];
};

ergophobe

4:17 pm on Jul 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Many store fronts, CMS systems and bulletin boards can't manage a single page without dozens of queries. As sites get more complex, you'll need more and more queries to get a page out.

The thing to watch is that

- You don't have queries executing inside loops unless it's genuinely necessary
- you index the columns you search on (at least in large tables without a lot of redundant entries in the given column)
- you don't use 2-3 queries where one will do

stuff like that

wener

5:31 pm on Jul 21, 2005 (gmt 0)

10+ Year Member



Thank you so much! I was afraid two queries would slow down the speed. Now I know it won't affect too much. Thank you!