Re: [rfc] overhauling pgstat.stat

Поиск
Список
Период
Сортировка
От Tomas Vondra
Тема Re: [rfc] overhauling pgstat.stat
Дата
Msg-id 52279C3F.4090704@fuzzy.cz
обсуждение исходный текст
Ответ на Re: [rfc] overhauling pgstat.stat  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Список pgsql-hackers
On 4.9.2013 20:59, Alvaro Herrera wrote:
> Tomas Vondra wrote:
> 
>> My idea was to keep the per-database stats, but allow some sort of
>> "random" access - updating / deleting the records in place, adding
>> records etc. The simplest way I could think of was adding a simple
>> "index" - a mapping of OID to position in the stat file.
>>
>> I.e. a simple  array of (oid, offset) pairs, stored in oid.stat.index or
>> something like that. This would make it quite simple to access existing
>> record
>>
>>   1: get position from the index
>>   2: read sizeof(Entry) from the file
>>   3: if it's update, just overwrite the bytes, for delete set isdeleted
>>      flag (needs to be added to all entries)
>>
>> or reading all the records (just read the whole file as today).
> 
> Sounds reasonable.  However, I think the index should be a real index,
> i.e. have a tree structure that can be walked down, not just a plain
> array.  If you have a 400 MB stat file, then you must have about 4
> million tables, and you will not want to scan such a large array every
> time you want to find an entry.

I was thinking about a sorted array, so a bisection would be a simple
and fast way to search. New items could be added to another small
unsorted array (say, 1000 elements) and this would be extended and
resorted only when this small one gets full.

Tomas



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

Предыдущее
От: Gavin Flower
Дата:
Сообщение: Re: INSERT...ON DUPLICATE KEY IGNORE
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Analysis on backend-private memory usage (and a patch)