Jump to content

Faster queries?


samoht

Recommended Posts

Hello All,

 

I am noticing that some of my pages are taking a few seconds to load, and I have a hunch my queries could be written better to speed things up.

 

One of my problems is that I have a ton of tables for many of my simple queries -

here is an example:

SELECT i.Name AS ItemName, pd.ItemId as Id, pd.ProductId, pd.Name, pd.PriceRetail, pp.PriceSell, i.ImagetnURL, QtyInStock, pack.PackageType, s.Name as Size 
FROM product pd, item i, productprice pp, itemfeatures itf, features f, packaging pack, size s, brands b
WHERE f.Name = '$pageTitle'
			AND pd.PackageId = pack.PackageId
			AND itf.FeatureId = f.FeatureId
			AND itf.ItemId = i.ItemId
			AND i.BrandId = b.BrandId
			AND pd.SizeId = s.SizeId
			AND pd.ItemId = i.ItemId
			AND pd.ProductId = pp.ProductId
			AND ClientPriceCode = 'R1'
ORDER BY pd.Name";

 

Do the multiple "AND" declarations slow things down??

 

what is a better/ faster way?

 

Thanks for the help,

Link to comment
https://forums.phpfreaks.com/topic/67910-faster-queries/
Share on other sites

the mysql page says;

 

"INNER JOIN and ,  (comma) are semantically equivalent in the absence of a join condition: both produce a Cartesian product between the specified tables (that is, each and every row in the first table is joined to each and every row in the second table)."

 

So does that mean that I was using INNER JOINS and didn't know it??

 

 

Link to comment
https://forums.phpfreaks.com/topic/67910-faster-queries/#findComment-341407
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.