Re: Query seem to slow if table have more than 200 million rows

From: "Qingqing Zhou" <zhouqq(at)cs(dot)toronto(dot)edu>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: Query seem to slow if table have more than 200 million rows
Date: 2005-10-03 23:04:50
Message-ID: dhs2t1$ge0$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance


""Ahmad Fajar"" <gendowo(at)konphalindo(dot)or(dot)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

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Ron Peacetree 2005-10-04 00:07:02 Re: [HACKERS] A Better External Sort?
Previous Message Josh Berkus 2005-10-03 22:03:11 Re: [HACKERS] A Better External Sort?