Re: Query seem to slow if table have more than 200 million rows - Mailing list pgsql-performance

From Qingqing Zhou
Subject Re: Query seem to slow if table have more than 200 million rows
Date
Msg-id dhs2t1$ge0$1@news.hub.org
Whole thread Raw
In response to Re: Query seem to slow if table have more than 200 million rows  ("Qingqing Zhou" <zhouqq@cs.toronto.edu>)
List pgsql-performance
""Ahmad Fajar"" <gendowo@konphalindo.or.id> wrote
> Hi Qingqing,
>
> I don't know whether the statistic got is bad or good, this is the
> statistic:

Please do it in this way:

1. Start postmaster with "stats_start_collector=true" and
"stats_block_level=true".

2. Use psql connect it, do something like this:

test=# select pg_stat_reset();
 pg_stat_reset
---------------
 t
(1 row)

test=# select * from pg_statio_user_indexes ;
 relid | indexrelid | schemaname | relname | indexrelname | idx_blks_read |
idx_
blks_hit
-------+------------+------------+---------+--------------+---------------+-----
---------
 16385 |      16390 | public     | test    | test_idx     |             0 |
       0
(1 row)

test=# select count(*) from test where a <= 1234;
 count
-------
  7243
(1 row)

test=# select * from pg_statio_user_indexes ;
 relid | indexrelid | schemaname | relname | indexrelname | idx_blks_read |
idx_
blks_hit
-------+------------+------------+---------+--------------+---------------+-----
---------
 16385 |      16390 | public     | test    | test_idx     |            55 |
       0
(1 row)


This gives us that to get "select count(*) from test where a <= 1234", I
have to read 55 index blocks (no index block hit since I just restart
postmaster so the bufferpool is empty).


Regards,
Qingqing



pgsql-performance by date:

Previous
From: Vivek Khera
Date:
Subject: Re: Ultra-cheap NVRAM device
Next
From: Josh Berkus
Date:
Subject: Re: [HACKERS] A Better External Sort?