Re: Can anyone make this code tighter? Too slow, Please help!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



shane.eckel@xxxxxxxxxxxxxxxxxxx wrote:
> I have this function in my C#.NET app that goes out to find the
> business units for each event and returns a string (for my report).
> I'm finding that for larger reports it takes too long and times out.
> 
> Does anyone know how I can speed this process up?  Is this code very
> tight or could it be cleaner?  thanks in advance for your help, this
> is a big issue used on several reports.

Perhaps try "EXPLAIN ANALYZE" on this query, given a valid event ID:

            SELECT     Distinct Companies.Name
                        FROM         Companies INNER JOIN
                      ExpenseAllocations ON Companies.ID =
ExpenseAllocations.BusinessUnitID
                        WHERE     (ExpenseAllocations.EventID =
@EventID)
                        ORDER BY Companies.Name DESC


#######
Do the columns used in the join and WHERE clause have indexes?

It's also possible the optimization needs to happen at a different level. Perhaps you are frequently
looking up the same results in a large report, or throughout the day.

If this part doesn't need to be up-to-second fresh, perhaps your application could
cache some of the results of this function, instead of repeatedly asking the database
to recompute it.

   Mark


[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux