Re: count(*) performance improvement ideas

Поиск
Список
Период
Сортировка
От Stephen Denne
Тема Re: count(*) performance improvement ideas
Дата
Msg-id F0238EBA67824444BC1CB4700960CB48051D6069@dmpeints002.isotach.com
обсуждение исходный текст
Ответ на Re: count(*) performance improvement ideas  (PFC <lists@peufeu.com>)
Ответы Re: count(*) performance improvement ideas  (PFC <lists@peufeu.com>)
Список pgsql-hackers
PFC wrote:
> Let's try this quick & dirty implementation of a local 
> count-delta cache  
> using a local in-memory hashtable (ie. {}).

> CREATE OR REPLACE FUNCTION update_count( key TEXT, delta INTEGER )
>    RETURNS INTEGER
> AS $$
>      if key in GD:
>              GD[key] += delta
>      else:
>              GD[key] = delta
>      return GD[key]
> $$ LANGUAGE plpythonu;

Thanks for the code, this seems to be very much what I was looking for.

I don't know plpythonu (nor python), just read a few docs now:
"The global dictionary SD is available to store data between function calls. This variable is private static data. The
globaldictionary GD is public data, available to all Python functions within a session. Use with care."
 

Does session == transaction or connection?
I don't understand the difference between SD and GD, private and public. Where are the context boundaries?

Regards,
Stephen Denne.

Disclaimer:
At the Datamail Group we value team commitment, respect, achievement, customer focus, and courage. This email with any
attachmentsis confidential and may be subject to legal privilege.  If it is not intended for you please advise by reply
immediately,destroy it and do not copy, disclose or use it in any way. 
__________________________________________________________________ This email has been scanned by the DMZGlobal
BusinessQuality             Electronic Messaging Suite. 
Please see http://www.dmzglobal.com/dmzmessaging.htm for details.
__________________________________________________________________


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

Предыдущее
От: "Stephen Denne"
Дата:
Сообщение: Re: count(*) performance improvement ideas
Следующее
От: Gregory Stark
Дата:
Сообщение: Re: How to submit a patch