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 3976DD9895 for ; Tue, 27 Sep 2005 06:36:21 -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 81244-08 for ; Tue, 27 Sep 2005 09:36:12 +0000 (GMT) Received: from ki-communication.com (unknown [202.147.194.21]) by svr1.postgresql.org (Postfix) with ESMTP id 10D12D9847 for ; Tue, 27 Sep 2005 06:36:01 -0300 (ADT) Received: from iacn01wks ([192.168.0.128]) by ki-communication.com with Microsoft SMTPSVC(6.0.3790.1830); Tue, 27 Sep 2005 16:40:18 +0700 From: "Ahmad Fajar" To: "'Qingqing Zhou'" Cc: Subject: Re: Query seem to slow if table have more than 200 million rows Date: Tue, 27 Sep 2005 16:39:55 +0700 Keywords: Postgresql MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.6353 In-Reply-To: Thread-Index: AcXC65FB7KmAMY4KTKSs6Z4F3k8iDgAWbRxA X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 Message-ID: X-OriginalArrivalTime: 27 Sep 2005 09:40:18.0765 (UTC) FILETIME=[78DB27D0:01C5C347] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.38 required=5 tests=[AWL=-0.112, DNS_FROM_RFC_WHOIS=0.492] X-Spam-Level: X-Archive-Number: 200509/368 X-Sequence-Number: 14676 Hi Qingqing, I don't know whether the statistic got is bad or good, this is the statistic: scooby=# select a.relid, a.relname, b.indexrelid, b.indexrelname, c.idx_scan, c.idx_tup_read, c.idx_tup_fetch, scooby-# a.heap_blks_read, a.heap_blks_hit, a.idx_blks_read, a.idx_blks_hit, scooby-# a.toast_blks_read, a.toast_blks_hit, a.tidx_blks_read, a.tidx_blks_hit, b.idx_blks_read, b.idx_blks_hit scooby-# from pg_statio_user_tables a, pg_statio_user_indexes b, pg_stat_all_indexes c scooby-# where a.relid=b.relid and a.relid=c.relid and b.indexrelid=c.indexrelid and a.relname=b.relname and scooby-# a.relname=c.relname and a.relname='fti_dict1'; relid | relname | indexrelid | indexrelname | idx_scan | idx_tup_read | idx_tup_fetch | heap_blks_read | heap_blks_hit | idx _blks_read | idx_blks_hit | toast_blks_read | toast_blks_hit | tidx_blks_read | tidx_blks_hit | idx_blks_read | idx_blks_hit ----------+-----------+------------+--------------+----------+-------------- +---------------+----------------+---------------+---- -----------+--------------+-----------------+----------------+-------------- --+---------------+---------------+-------------- 22880226 | fti_dict1 | 22880231 | idx_dict3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | | | | | 0 | 0 22880226 | fti_dict1 | 22880230 | idx_dict2 | 7 | 592799 | 592799 | 0 | 0 | 0 | 0 | | | | | 0 | 0 22880226 | fti_dict1 | 22880229 | idx_dict1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | | | | | 0 | 0 (3 rows) I have try several time the query below with different keyword, but I just got idx_tup_read and idx_tup_fetch changed, others keep zero. The Index are: Ids (Idx_dict1), keywords (idx_dict2 varchar_ops), keywords (idx_dict3 varchar_pattern_ops) ==> I use this index for query ... keywords like 'blabla%', just for testing purpose Regards, ahmad fajar -----Original Message----- From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Qingqing Zhou Sent: Selasa, 27 September 2005 8:43 To: pgsql-performance@postgresql.org Subject: Re: [PERFORM] Query seem to slow if table have more than 200 million rows ""Ahmad Fajar"" wrote > > Select ids, keywords from dict where keywords='blabla' ('blabla' is a > single > word); > > The table have 200 million rows, I have index the keywords field. On the > first time my query seem to slow to get the result, about 15-60 sec to get > the result. But if I repeat the query I will get fast result. My question > is > why on the first time the query seem very slow. > > Table structure is quite simple: > > Ids bigint, keywords varchar(150), weight varchar(1), dpos int. > The first slowness is obviously caused by disk IOs. The second time is faster because all data pages it requires are already in buffer pool. 200 million rows is not a problem for btree index, even if your client tool appends some spaces to your keywords at your insertion time, the ideal btree is 5 to 6 layers high at most. Can you show the iostats of index from your statistics view? http://www.postgresql.org/docs/8.0/static/monitoring-stats.html#MONITORING-S TATS-VIEWS Regards, Qingqing ---------------------------(end of broadcast)--------------------------- TIP 6: explain analyze is your friend