Multiple Database Queries: How big a performance hit? -
11-02-2005
, 06:46 PM
I'm displaying four categories of information from four tables in four
locations. It was hard to figure out how to do it all with one query, so
I made four separate queries. It works fine locally, but my online pages
load extremely slowly. I haven't yet figured out if the problem is with
my scripts or my online database. However, I wondered how much, if any,
it might speed things up if I combined queries.
These two queries are very similar...
$area_res = mysql_query("SELECT DISTINCT GWEA.NameEA FROM gwgeogeco
as GWEA
INNER JOIN gzecoregions AS GZER ON GZER.Place = GWEA.IDArea
WHERE GZER.Animal = '$_GET[$MyGet]' LIMIT 10");
$Biome = mysql_query("SELECT Biome FROM gwgeogeco as GWEA
INNER JOIN gzecoregions AS GZER ON GZER.Place = GWEA.IDArea
WHERE GZER.Animal = '$_GET[$MyGet]' GROUP BY Biome");
Table gzecoregions is huge, with about 350,000 rows, though just three
fields. I think gzecoregions has less than 1,000 rows. The other two
queries involve the same tables but inner join on one or two additional
tables.
Anyway, do you think combining queries would make much difference in
performance?
Thanks. |