On Wed, July 20, 2005 10:02 am, Shaw, Chris - Accenture said: > I recommend redesigning your query, the database can pull back the records > you want far quicker than any frontend combining/processing, since that's > what T-SQL and relational database were designed for. This is usually true, and almost always true for Beginners, but is not actually *ALWAYS* true. There are circumstances where separate queries from PHP can drastically improve DB performance, in my experience. I suspect these generally boil down to the database having limited swap/RAM space to work in, rather than some kind of super special SQL juju I was running into. > This is not a wonderful example, because I could LEFT JOIN pos to > parts. But I have more complex queries that have several INNER/LEFT > joins that once I bring in that last table to complete my query it > (the last table) skews my sums. Really I'm just wondering if others > have come across This, however, does sound more like an SQL problem... Though I also have had cases where what SQL did when I was trying to JOIN a bunch of tables and get statistical data and what I *thought* it was doing did not match. The worst of it is, the numbers "look" reasonable, so you never find out until somebody sits down with pencil and paper and works out what the answer SHOULD be. Ugh. Then, you sit there and stare at the SQL and realize you have NO IDEA how to express what you actually mean to say in SQL in a single statement. At a certain point, the time involved just to prove the answer correct on realistic data is more than the cost of just doing it in stages in PHP where you *KNOW* you understand what the SQL is doing and you *KNOW* you've got the right numbers. * Maybe I'm just an SQL moron. Or maybe SQL is just too damn complex for its own good. Take your pick. * If your SQL software has Stored Procedures, this is a really nifty time to start using them, rather than PHP and staged calculations... If your SQL has not Stored Procedures... [shrug] Do it in PHP and make sure it can handle the load. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php