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 DFAB0D9761 for ; Mon, 26 Sep 2005 19:43:23 -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 24523-03 for ; Mon, 26 Sep 2005 22:43:14 +0000 (GMT) Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) by svr1.postgresql.org (Postfix) with ESMTP id D9C52D975A for ; Mon, 26 Sep 2005 19:43:15 -0300 (ADT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id 683CF31F51; Tue, 27 Sep 2005 00:43:18 +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, 26 Sep 2005 18:43:14 -0700 Organization: Hub.Org Networking Services Lines: 30 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.195 required=5 tests=[AWL=0.010, PRIORITY_NO_NAME=1.185] X-Spam-Level: * X-Archive-Number: 200509/362 X-Sequence-Number: 14670 ""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-STATS-VIEWS Regards, Qingqing