X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 87FCA3A3B0F for ; Wed, 24 Nov 2004 10:39:34 +0000 (GMT) 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 09089-08 for ; Wed, 24 Nov 2004 10:39:27 +0000 (GMT) Received: from bluebamboo.ph (unknown [202.175.252.53]) by svr1.postgresql.org (Postfix) with ESMTP id EAB453A3D33 for ; Wed, 24 Nov 2004 10:39:25 +0000 (GMT) Received: from irridescens ([192.168.0.180]) by bluebamboo.ph (8.11.6/8.11.6) with ESMTP id iAOAeHi00566; Wed, 24 Nov 2004 18:40:20 +0800 From: "BBI Edwin Punzalan" To: "'Richard Huxton'" Cc: Subject: Re: FW: FW: Index usage Date: Wed, 24 Nov 2004 18:39:52 +0800 Message-ID: <000701c4d211$f039bfd0$b400a8c0@bluebamboo.ph> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.4510 In-Reply-To: <41A45F95.70206@archonet.com> x-mimeole: Produced By Microsoft MimeOLE V6.00.2900.2180 Importance: Normal X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/374 X-Sequence-Number: 9328 Hi. 1) chatlogs rows increases every now and then (its in a live environment) and currently have 538,696 rows 2) this is the only problem we experienced. So far, all our other indexes are being used correctly. 3) I don't remember tuning any post-installation configuration of our postgreSQL except setting fsync to false. Thanks for taking a look at our problem. :D -----Original Message----- From: Richard Huxton [mailto:dev@archonet.com] Sent: Wednesday, November 24, 2004 6:17 PM To: BBI Edwin Punzalan Cc: pgsql-performance@postgresql.org Subject: Re: FW: [PERFORM] FW: Index usage BBI Edwin Punzalan wrote: > Thanks, Tim. > > I tried adding an upper limit and its still the same as follows: > > ============== > db=# explain analyze select date from chatlogs where date>='11/24/04'; > NOTICE: QUERY PLAN: > > Index Scan using chatlogs_date_idx on chatlogs (cost=0.00..145.72 > rows=37 > width=4) (actual time=0.18..239.69 rows=10737 loops=1) > Total runtime: 246.22 msec > > EXPLAIN > db=# explain analyze select date from chatlogs where date>='11/23/04' > and date<'11/24/04'; > NOTICE: QUERY PLAN: > > Seq Scan on chatlogs (cost=0.00..24763.19 rows=9200 width=4) (actual > time=0.44..4447.01 rows=13029 loops=1) Total runtime: 4455.56 msec We have two issues here 1. In the first example it only picks an index because it thinks it is going to get 37 rows, it actually gets 10737 2. It's taking 4455ms to run a seq-scan but only 246ms to run an index-scan over 10737 rows (and then fetch the rows too). Questions: 1. How many rows do you have in chatlogs? 2. Is this the only problem you are experiencing, or just one from many? 3. Have you tuned any configuration settings? e.g. as suggested in: http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html -- Richard Huxton Archonet Ltd