SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast rikdc's Avatar
    Join Date
    Sep 2005
    Location
    Edinburgh
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    several calculated columns

    Hi
    I have a page which lists details of customers, and status indicators of their activity around the system. There are 12 areas all together, and each status is calculated based on data in the database. The problem is, this sets for 12 queries to be run per customer, so on a page showing just ten customers equates to 120 queries.

    I was wondering about using some triggers to update a table which can be queried in one to get these statuses. It means that some of the status-decisions logic is duplicated (some in the client code, some in the database), but I can't think of any better way to approach it. Maybe a postgres function to get all 12 statuses, but that only deferrs the 12 queries to another layer.

    Any thoughts?

    Thank you

  2. #2
    SitePoint Guru MikeBigg's Avatar
    Join Date
    Jun 2004
    Location
    Reading, UK
    Posts
    970
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Would a view help? Still pushing the 12 queries into another level, but maybe more efficient there.

    Mike

  3. #3
    SitePoint Enthusiast rikdc's Avatar
    Join Date
    Sep 2005
    Location
    Edinburgh
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    aye, I was looking at a view - seems to be a little faster than the function as well

  4. #4
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    can you post those 12 queries in a text attachment?


Bookmarks

Posting Permissions

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