www.webdeveloper.com
Results 1 to 4 of 4

Thread: Array or Multiple Querys or ...?

  1. #1
    Join Date
    Feb 2012
    Location
    Tallahassee, FL
    Posts
    280

    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?

  2. #2
    Join Date
    Apr 2010
    Posts
    88
    One query is better. You should always try to reduce the number of SQL queries.

  3. #3
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    18,912
    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

    eBookworm.us

  4. #4
    Join Date
    Feb 2012
    Location
    Tallahassee, FL
    Posts
    280
    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles