Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id E6DEE2E0042 for ; Tue, 6 May 2008 02:37:08 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 96079-01 for ; Tue, 6 May 2008 02:36:57 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from mail.emproshunts.com (mail.emproshunts.com [66.64.191.19]) by developer.postgresql.org (Postfix) with ESMTP id C0C532E003C for ; Tue, 6 May 2008 02:36:38 -0300 (ADT) Received: from [192.168.1.49] by mail.emproshunts.com (GMS 15.00.3626/KX5895.00.ca7cb0e7) with ESMTP id tsxlhaaa for pgsql-performance@postgresql.org; Tue, 6 May 2008 01:36:36 -0400 Message-ID: <481FEE64.2@emproshunts.com> Date: Tue, 06 May 2008 00:36:36 -0500 From: Justin User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) MIME-Version: 1.0 To: Scott Marlowe , pgsql-performance@postgresql.org Subject: Re: need to speed up query References: <481FBC0D.7010509@emproshunts.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [192.168.1.49] X-DNSBL: 0 X-AntiSpam: Checked for restricted content by Gordano's AntiSpam Software X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/69 X-Sequence-Number: 30037 yes the cross join is intentional. Thanks creating the two column index drop processing time to 15 to 17 seconds put per period down to 1 second Scott Marlowe wrote: > You're joining these two tables: period, accnt, but I'm not seeing an > on () clause or a where clause joining them. Is the cross product > intentional? > > But what I'm seeing that seems like the lowest hanging fruit would be > two column indexes on the bits that are showing up in those bit map > scans. Like this part: > > " Recheck Cond: ((gltrans_date <= $3) AND > (gltrans_date >= $0) AND gltrans_accnt_id = $1))" > " Filter: gltrans_posted" > " -> BitmapAnd (cost=38.90..38.90 rows=10 > width=0) (actual time=0.839..0.839 rows=0 loops=1729)" > " -> Bitmap Index Scan on > gltrans_gltrans_date_idx (cost=0.00..8.08 rows=382 width=0) (actual > time=0.782..0.782 rows=5872 loops=1729)" > " Index Cond: ((gltrans_date <= $3) > AND (gltrans_date >= $0))" > " -> Bitmap Index Scan on > gltrans_gltrans_accnt_id_idx (cost=0.00..30.57 rows=1908 width=0) > (actual time=0.076..0.076 rows=574 loops=798)" > " Index Cond: (gltrans_accnt_id = $1)" > > You are looking through 574 rows in one column and 5872 in another. > But when they're anded together, you get 0 rows. A two column index > there should really help. > >