Re: count(*) performance improvement ideas

Поиск
Список
Период
Сортировка
Искать
От
Stephen Denne
Тема
Re: count(*) performance improvement ideas
Дата
Msg-id
F0238EBA67824444BC1CB4700960CB48051D6069@dmpeints002.isotach.com
Ответ на
Список
Дерево обсуждения
Re: count(*) performance improvement ideas "Stephen Denne" <Stephen.Denne@datamail.co.nz>
Re: count(*) performance improvement ideas Tom Lane <tgl@sss.pgh.pa.us>
Re: count(*) performance improvement ideas Magnus Hagander <magnus@hagander.net>
Re: count(*) performance improvement ideas Tom Lane <tgl@sss.pgh.pa.us>
Re: count(*) performance improvement ideas Bruce Momjian <bruce@momjian.us>
Re: count(*) performance improvement ideas Joe Conway <mail@joeconway.com>
Re: count(*) performance improvement ideas Tom Lane <tgl@sss.pgh.pa.us>
Re: count(*) performance improvement ideas "Stephen Denne" <Stephen.Denne@datamail.co.nz>
Re: count(*) performance improvement ideas Tom Lane <tgl@sss.pgh.pa.us>
Re: count(*) performance improvement ideas "Stephen Denne" <Stephen.Denne@datamail.co.nz>
Re: count(*) performance improvement ideas PFC <lists@peufeu.com>
Re: count(*) performance improvement ideas "Stephen Denne" <Stephen.Denne@datamail.co.nz>
Re: count(*) performance improvement ideas PFC <lists@peufeu.com>
Re: count(*) performance improvement ideas "Stephen Denne" <Stephen.Denne@datamail.co.nz>
Re: count(*) performance improvement ideas "Stephen Denne" <Stephen.Denne@datamail.co.nz>
Re: count(*) performance improvement ideas PFC <lists@peufeu.com>
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 global dictionary 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 attachments is 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 Business Quality             Electronic Messaging Suite.
Please see http://www.dmzglobal.com/dmzmessaging.htm for details.
__________________________________________________________________

В списке pgsql-hackers по дате отправления
От: Stephen Denne
Дата:
От: Gregory Stark
Дата:
Сообщение: Re: How to submit a patch
FAQ