Обсуждение: Check memory consumption of postgresql query

Поиск
Список
Период
Сортировка

Check memory consumption of postgresql query

От
Phan Công Minh
Дата:
Hello PostgreSQL community ,

I'm doing benchmark between column store and traditional row-oriented store. I would like to know if there is any way to measure memory consummed by a query execution?

Thanks
Minh,

Re: Check memory consumption of postgresql query

От
Clinton Adams
Дата:
On Thu, May 8, 2014 at 3:04 AM, Phan Công Minh <cphan@hsr.ch> wrote:
> Hello PostgreSQL community ,
>
> I'm doing benchmark between column store and traditional row-oriented store.
> I would like to know if there is any way to measure memory consummed by a
> query execution?


In linux you can look at the memory usage for a particular backend in
/proc/[pid]/smaps. Get the pid with pg_backend_pid() or from
pg_stat_activity.

For more info, check out
http://www.depesz.com/2012/06/09/how-much-ram-is-postgresql-using/

- Clinton


>
> Thanks
> Minh,
>


Re: Check memory consumption of postgresql query

От
Phan Công Minh
Дата:
Hi Clinton,

Thank you for your response. I check the article (http://www.depesz.com/2012/06/09/how-much-ram-is-postgresql-using/)
andit seems to work with general process as well.  
However does it have anyway to calculate the memory used by single query, not the whole postgresql process?

Thanks,
Minh
________________________________________
From: Clinton Adams <clinton.adams@gmail.com>
Sent: Thursday, May 8, 2014 4:04 PM
To: Phan Công Minh
Cc: pgsql-performance@postgresql.org
Subject: Re: [PERFORM] Check memory consumption of postgresql query

On Thu, May 8, 2014 at 3:04 AM, Phan Công Minh <cphan@hsr.ch> wrote:
> Hello PostgreSQL community ,
>
> I'm doing benchmark between column store and traditional row-oriented store.
> I would like to know if there is any way to measure memory consummed by a
> query execution?


In linux you can look at the memory usage for a particular backend in
/proc/[pid]/smaps. Get the pid with pg_backend_pid() or from
pg_stat_activity.

For more info, check out
http://www.depesz.com/2012/06/09/how-much-ram-is-postgresql-using/

- Clinton


>
> Thanks
> Minh,
>

Re: Check memory consumption of postgresql query

От
Matheus de Oliveira
Дата:

On Mon, May 12, 2014 at 4:02 AM, Phan Công Minh <cphan@hsr.ch> wrote:
Thank you for your response. I check the article (http://www.depesz.com/2012/06/09/how-much-ram-is-postgresql-using/) and it seems to work with general process as well.
However does it have anyway to calculate the memory used by single query, not the whole postgresql process?

You can check only the /proc/<pid>/ for the backend you are interested in. Also, an EXPLAIN ANALYZE of your qurey will show memory used by some operations (like sort, hash, etc.), those are limited by the work_mem parameter, so if you are working on benchmarks, you may want to tune that properly.

Regards,
--
Matheus de Oliveira
Analista de Banco de Dados
Dextra Sistemas - MPS.Br nível F!
www.dextra.com.br/postgres