Array or Multiple Querys or ...?
I am making a report that pulls data from sales from any date to any date. Currently, it makes about 50 queries. I thought it would make more sense to just have one query, store the results in an array and use that. But that seems to be about the same. Any tips?
One query is better. You should always try to reduce the number of SQL queries.
50 separate queries certainly seems excessive. While I don't always try to get down to "one query that rules them all," if just for maintainability reasons, I'd certainly consider 50 queries to be a good reason for some refactoring.
Now, as to whether it should be put into one array that you work with or if you can iterate through the result set one at a time, that's more dependent on how your application is structured and precisely what you are trying to do.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
How to Ask Questions the Smart Way
(not affiliated with this site, but well worth reading)
Yeah, I didnt make it. It is a sales report, and it pulls multiple rows at a time. Im just trying to speed it up.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)