X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 15BA1D83DE for ; Mon, 3 Oct 2005 17:04:59 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 11210-04 for ; Mon, 3 Oct 2005 20:04:55 +0000 (GMT) Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) by svr1.postgresql.org (Postfix) with ESMTP id 86E97D9EE1 for ; Mon, 3 Oct 2005 17:04:54 -0300 (ADT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id 0346331F51; Mon, 3 Oct 2005 22:04:55 +0200 (MET DST) From: "Qingqing Zhou" X-Newsgroups: pgsql.performance Subject: Re: Query seem to slow if table have more than 200 million rows Date: Mon, 3 Oct 2005 16:04:50 -0700 Organization: Hub.Org Networking Services Lines: 56 Message-ID: References: X-Complaints-To: usenet@news.hub.org X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-RFC2646: Format=Flowed; Original To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.192 required=5 tests=[AWL=0.007, PRIORITY_NO_NAME=1.185] X-Spam-Level: * X-Archive-Number: 200510/23 X-Sequence-Number: 14791 ""Ahmad Fajar"" 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