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

Поиск
Список
Период
Сортировка
От Mark Stosberg
Тема Re: Can anyone make this code tighter? Too slow, Please help!
Дата
Msg-id eqinlp$2vg7$1@news.hub.org
обсуждение исходный текст
Список pgsql-performance
shane.eckel@seattlesoftware.com 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

В списке pgsql-performance по дате отправления:

Предыдущее
От: Mark Stosberg
Дата:
Сообщение: cube operations slower than geo_distance() on production server
Следующее
От: "Virag Saksena"
Дата:
Сообщение: Is there an equivalent for Oracle's user_tables.num_rows