pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
how to know whether query data from memory after pg_prewarm
6+ messages / 4 participants
[nested] [flat]

* how to know whether query data from memory after pg_prewarm
@ 2018-09-19 01:34 jimmy <mpokky@126.com>
  2018-09-19 03:29 ` Re: how to know whether query data from memory after pg_prewarm Thomas Munro <thomas.munro@enterprisedb.com>
  0 siblings, 1 reply; 6+ messages in thread

From: jimmy @ 2018-09-19 01:34 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

I use select pg_prewarm('table1','read','main')  to load data of table1 into the memory.
when I use select count(1) from table1 group by aa to query data.
I find the speed of query is not fast, I wonder whether it query data from memory.
And it is slower than Oracle, both of Oracle and Postgresql has same table and count of data.
when pg_prewarm use 'read' mode,  the data is put into the OS cache, how to examine the table which is pg_prewarmed into the OS cache .
I know pg_buffercache ,but it just examine the table in the shared buffer of Postgresql, not the table in the OS cache.

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: how to know whether query data from memory after pg_prewarm
  2018-09-19 01:34 how to know whether query data from memory after pg_prewarm jimmy <mpokky@126.com>
@ 2018-09-19 03:29 ` Thomas Munro <thomas.munro@enterprisedb.com>
  2018-09-19 07:42   ` Re: how to know whether query data from memory after pg_prewarm Fabio Pardi <f.pardi@portavita.eu>
  2018-09-19 07:44   ` Re: how to know whether query data from memory after pg_prewarm Cédric Villemain <cedric@2ndQuadrant.com>
  0 siblings, 2 replies; 6+ messages in thread

From: Thomas Munro @ 2018-09-19 03:29 UTC (permalink / raw)
  To: jimmy <mpokky@126.com>; +Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>

On Wed, Sep 19, 2018 at 1:35 PM jimmy <mpokky@126.com> wrote:
> I use select pg_prewarm('table1','read','main')  to load data of table1 into the memory.
> when I use select count(1) from table1 group by aa to query data.
> I find the speed of query is not fast, I wonder whether it query data from memory.
> And it is slower than Oracle, both of Oracle and Postgresql has same table and count of data.
> when pg_prewarm use 'read' mode,  the data is put into the OS cache, how to examine the table which is pg_prewarmed into the OS cache .
> I know pg_buffercache ,but it just examine the table in the shared buffer of Postgresql, not the table in the OS cache.

This is a quick and dirty hack, but it might do what you want:

https://github.com/macdice/pgdata_mincore

Tested on FreeBSD, not sure how well it'll travel.

-- 
Thomas Munro
http://www.enterprisedb.com




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: how to know whether query data from memory after pg_prewarm
  2018-09-19 01:34 how to know whether query data from memory after pg_prewarm jimmy <mpokky@126.com>
  2018-09-19 03:29 ` Re: how to know whether query data from memory after pg_prewarm Thomas Munro <thomas.munro@enterprisedb.com>
@ 2018-09-19 07:42   ` Fabio Pardi <f.pardi@portavita.eu>
  1 sibling, 0 replies; 6+ messages in thread

From: Fabio Pardi @ 2018-09-19 07:42 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

@Thomas, this tool looks very interesting!

@Jimmy:

Back to the question,you might approach the problem from a different perspective..

If you run a query 2 consecutive times, from the secondon, you should be at 'full speed'.

Therefore if the first run takes X seconds but the consecutive runs take only a fraction of it, then you have probably cached all the data.

It might be as simple as that. Butalsotake into account:

- What is written above is true when the size of the table fits in RAM
- No other activity is going on. If you have other activity going on on the disk, it will pollute your results
- If you read from disk, you will see read activity on the data disk, given that your are graphing it. If is cached then it does not read from disk.
- Running the query with 'explain' will tell you in detail what is going on. (Maybe you forgot to create an index on Postgres and is there on Oracle?)
- If you are doing sortsand the data does not fit on work_mem then you are making use of disk space, slowing down operations


regards,

fabio pardi


On 19/09/18 05:29, Thomas Munro wrote:
> On Wed, Sep 19, 2018 at 1:35 PM jimmy <mpokky@126.com> wrote:
>> I use select pg_prewarm('table1','read','main')  to load data of table1 into the memory.
>> when I use select count(1) from table1 group by aa to query data.
>> I find the speed of query is not fast, I wonder whether it query data from memory.
>> And it is slower than Oracle, both of Oracle and Postgresql has same table and count of data.
>> when pg_prewarm use 'read' mode,  the data is put into the OS cache, how to examine the table which is pg_prewarmed into the OS cache .
>> I know pg_buffercache ,but it just examine the table in the shared buffer of Postgresql, not the table in the OS cache.
> This is a quick and dirty hack, but it might do what you want:
>
> https://github.com/macdice/pgdata_mincore
>
> Tested on FreeBSD, not sure how well it'll travel.
>

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: how to know whether query data from memory after pg_prewarm
  2018-09-19 01:34 how to know whether query data from memory after pg_prewarm jimmy <mpokky@126.com>
  2018-09-19 03:29 ` Re: how to know whether query data from memory after pg_prewarm Thomas Munro <thomas.munro@enterprisedb.com>
@ 2018-09-19 07:44   ` Cédric Villemain <cedric@2ndQuadrant.com>
  2018-09-19 21:38     ` Re: how to know whether query data from memory after pg_prewarm Thomas Munro <thomas.munro@enterprisedb.com>
  2018-09-26 05:50     ` Re:Re: how to know whether query data from memory after pg_prewarm jimmy <mpokky@126.com>
  1 sibling, 2 replies; 6+ messages in thread

From: Cédric Villemain @ 2018-09-19 07:44 UTC (permalink / raw)
  To: Thomas Munro <thomas.munro@enterprisedb.com>; jimmy <mpokky@126.com>; +Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>

Le 19/09/2018 à 05:29, Thomas Munro a écrit :
> On Wed, Sep 19, 2018 at 1:35 PM jimmy <mpokky@126.com> wrote:
>> I use select pg_prewarm('table1','read','main')  to load data of table1 into the memory.
>> when I use select count(1) from table1 group by aa to query data.
>> I find the speed of query is not fast, I wonder whether it query data from memory.
>> And it is slower than Oracle, both of Oracle and Postgresql has same table and count of data.
>> when pg_prewarm use 'read' mode,  the data is put into the OS cache, how to examine the table which is pg_prewarmed into the OS cache .
>> I know pg_buffercache ,but it just examine the table in the shared buffer of Postgresql, not the table in the OS cache.
> 
> This is a quick and dirty hack, but it might do what you want:
> 
> https://github.com/macdice/pgdata_mincore
> 
> Tested on FreeBSD, not sure how well it'll travel.

You can use pgfincore extension for that purpose, and more.

https://github.com/klando/pgfincore/blob/master/README.md


-- 
Cédric Villemain +33 (0)6 20 30 22 52
http://2ndQuadrant.fr/
PostgreSQL: Support 24x7 - Développement, Expertise et Formation




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: how to know whether query data from memory after pg_prewarm
  2018-09-19 01:34 how to know whether query data from memory after pg_prewarm jimmy <mpokky@126.com>
  2018-09-19 03:29 ` Re: how to know whether query data from memory after pg_prewarm Thomas Munro <thomas.munro@enterprisedb.com>
  2018-09-19 07:44   ` Re: how to know whether query data from memory after pg_prewarm Cédric Villemain <cedric@2ndQuadrant.com>
@ 2018-09-19 21:38     ` Thomas Munro <thomas.munro@enterprisedb.com>
  1 sibling, 0 replies; 6+ messages in thread

From: Thomas Munro @ 2018-09-19 21:38 UTC (permalink / raw)
  To: cedric@2ndquadrant.com; +Cc: jimmy <mpokky@126.com>; pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>

On Wed, Sep 19, 2018 at 7:44 PM Cédric Villemain <cedric@2ndquadrant.com> wrote:
> Le 19/09/2018 à 05:29, Thomas Munro a écrit :
> > On Wed, Sep 19, 2018 at 1:35 PM jimmy <mpokky@126.com> wrote:
> >> I use select pg_prewarm('table1','read','main')  to load data of table1 into the memory.
> >> when I use select count(1) from table1 group by aa to query data.
> >> I find the speed of query is not fast, I wonder whether it query data from memory.
> >> And it is slower than Oracle, both of Oracle and Postgresql has same table and count of data.
> >> when pg_prewarm use 'read' mode,  the data is put into the OS cache, how to examine the table which is pg_prewarmed into the OS cache .
> >> I know pg_buffercache ,but it just examine the table in the shared buffer of Postgresql, not the table in the OS cache.
> >
> > This is a quick and dirty hack, but it might do what you want:
> >
> > https://github.com/macdice/pgdata_mincore
> >
> > Tested on FreeBSD, not sure how well it'll travel.
>
> You can use pgfincore extension for that purpose, and more.
>
> https://github.com/klando/pgfincore/blob/master/README.md

Yes, if you only want to know *how many* pages are in the OS page
cache.  pgdata_mincore shows you which PG blocks are in the page cache
in the same format as pg_buffercache, which is useful for studying
double buffering effects.  Maybe I should turn it into a patch for
pgfincore...

-- 
Thomas Munro
http://www.enterprisedb.com




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re:Re: how to know whether query data from memory after pg_prewarm
  2018-09-19 01:34 how to know whether query data from memory after pg_prewarm jimmy <mpokky@126.com>
  2018-09-19 03:29 ` Re: how to know whether query data from memory after pg_prewarm Thomas Munro <thomas.munro@enterprisedb.com>
  2018-09-19 07:44   ` Re: how to know whether query data from memory after pg_prewarm Cédric Villemain <cedric@2ndQuadrant.com>
@ 2018-09-26 05:50     ` jimmy <mpokky@126.com>
  1 sibling, 0 replies; 6+ messages in thread

From: jimmy @ 2018-09-26 05:50 UTC (permalink / raw)
  To: Cédric Villemain <cedric@2ndQuadrant.com>; +Cc: Thomas Munro <thomas.munro@enterprisedb.com>; pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>

But I use windows server 2012R.
pgfincore can not run on the windows.
Is there some replacements in windows system?








At 2018-09-19 15:44:06, "Cédric Villemain" <cedric@2ndQuadrant.com> wrote:
>Le 19/09/2018 à 05:29, Thomas Munro a écrit :
>> On Wed, Sep 19, 2018 at 1:35 PM jimmy <mpokky@126.com> wrote:
>>> I use select pg_prewarm('table1','read','main')  to load data of table1 into the memory.
>>> when I use select count(1) from table1 group by aa to query data.
>>> I find the speed of query is not fast, I wonder whether it query data from memory.
>>> And it is slower than Oracle, both of Oracle and Postgresql has same table and count of data.
>>> when pg_prewarm use 'read' mode,  the data is put into the OS cache, how to examine the table which is pg_prewarmed into the OS cache .
>>> I know pg_buffercache ,but it just examine the table in the shared buffer of Postgresql, not the table in the OS cache.
>> 
>> This is a quick and dirty hack, but it might do what you want:
>> 
>> https://github.com/macdice/pgdata_mincore
>> 
>> Tested on FreeBSD, not sure how well it'll travel.
>
>You can use pgfincore extension for that purpose, and more.
>
>https://github.com/klando/pgfincore/blob/master/README.md
>
>
>-- 
>Cédric Villemain +33 (0)6 20 30 22 52
>http://2ndQuadrant.fr/
>PostgreSQL: Support 24x7 - Développement, Expertise et Formation


^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2018-09-26 05:50 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-09-19 01:34 how to know whether query data from memory after pg_prewarm jimmy <mpokky@126.com>
2018-09-19 03:29 ` Thomas Munro <thomas.munro@enterprisedb.com>
2018-09-19 07:42   ` Fabio Pardi <f.pardi@portavita.eu>
2018-09-19 07:44   ` Cédric Villemain <cedric@2ndQuadrant.com>
2018-09-19 21:38     ` Thomas Munro <thomas.munro@enterprisedb.com>
2018-09-26 05:50     ` jimmy <mpokky@126.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox