Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id CF69C632662 for ; Mon, 6 Apr 2009 00:35:26 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 55959-05 for ; Mon, 6 Apr 2009 00:35:23 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.vanten.com (doc.vanten.com [203.216.141.136]) by mail.postgresql.org (Postfix) with ESMTP id F39426324C2 for ; Mon, 6 Apr 2009 00:35:22 -0300 (ADT) Received: from hexagon.office.vanten.com (hexagon.office.vanten.com [192.168.220.16]) by mail.vanten.com (Postfix) with ESMTP id AA36B4119 for ; Mon, 6 Apr 2009 12:35:20 +0900 (JST) Received: from Espresso (Espresso.office.vanten.com [192.168.220.80]) by hexagon.office.vanten.com (Postfix) with ESMTP id 9A0613C48B for ; Mon, 6 Apr 2009 12:35:20 +0900 (JST) From: "Rainer Mager" To: References: <003001c9b645$e8a7cec0$b9f76c40$@com> <003501c9b656$a9c73fe0$fd55bfa0$@com> <7371.1238981597@sss.pgh.pa.us> In-Reply-To: <7371.1238981597@sss.pgh.pa.us> Subject: Re: difficulties with time based queries Date: Mon, 6 Apr 2009 12:35:36 +0900 Message-ID: <003601c9b668$bf63c2d0$3e2b4870$@com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: Acm2V67taS6N+dZOSV+76Ry0403szgAD8gPg Content-Language: en-us X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200904/116 X-Sequence-Number: 33483 > -----Original Message----- > From: Tom Lane [mailto:tgl@sss.pgh.pa.us] > "Rainer Mager" writes: > >> From: Tom Lane [mailto:tgl@sss.pgh.pa.us] > >> Hmm ... it's pretty unusual to see the index fetch portion of a > bitmap > >> scan take the bulk of the runtime. Usually that part is fast and > where > >> the pain comes is in fetching from the heap. I wonder whether that > >> index has become bloated. How big are the table and the index > >> physically? (Look at pg_class.relpages, or if you want a really > >> accurate number try pg_relation_size().) > > > Can you give me some more info on how to look at these stats? > > Since you've got 8.3 it's easy: select pg_relation_size('tablename') > (or indexname). The result is in bytes, so you might want to > divide by 1K or 1M to keep the number readable. Ok, nice and simple...I like it: The result for the table ad_log, is 30,063 MB. The result for the index, ad_log_date_all, is 17,151 MB. I guess this roughly makes sense since the index is on 4 fields and the table only has 6 fields. For the particular query I'm trying to optimize at the moment I believe I should be able to use an index that references only 2 fields, which, I imagine, should reduce the time needed to read it. I'll play with this a bit and see what happens. Any other suggestions? --Rainer