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 56BB83A4716 for ; Thu, 18 Nov 2004 15:40:03 +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 25861-07 for ; Thu, 18 Nov 2004 15:39:57 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id E83C73A46FC for ; Thu, 18 Nov 2004 15:39:59 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iAIFdxeU016866; Thu, 18 Nov 2004 10:39:59 -0500 (EST) To: "Andrew Janian" Cc: pgsql-performance@postgresql.org Subject: Re: Query Performance and IOWait In-reply-to: References: Comments: In-reply-to "Andrew Janian" message dated "Thu, 18 Nov 2004 07:42:20 -0600" Date: Thu, 18 Nov 2004 10:39:59 -0500 Message-ID: <16865.1100792399@sss.pgh.pa.us> From: Tom Lane 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/285 X-Sequence-Number: 9239 "Andrew Janian" writes: > QUERY PLAN > Nested Loop IN Join (cost=0.00..34047.29 rows=1 width=526) > -> Index Scan using mfi_log_time on mb_fix_message (cost=0.00..22231.31 rows=2539 width=526) > Index Cond: ((msg_log_time > '2004-06-01 00:00:00'::timestamp without time zone) AND (msg_log_time < '2004-06-01 23:59:59.999'::timestamp without time zone)) > Filter: (((msg_message_type)::text = '8'::text) AND (((mb_raw_text)::text ~~ '%39=1%'::text) OR ((mb_raw_text)::text ~~ '%39=2%'::text))) > -> Index Scan using mfi_client_ordid on mb_fix_message (cost=0.00..445.56 rows=1 width=18) > Index Cond: (("outer".msg_client_order_id)::text = (mb_fix_message.msg_client_order_id)::text) > Filter: ((msg_log_time >= '2004-06-01 00:00:00'::timestamp without time zone) AND (msg_log_time < '2004-06-01 13:30:00'::timestamp without time zone) AND ((msg_message_type)::text = 'D'::text) OR ((msg_message_type)::text = 'G'::text)) AND ((mb_ord_type)::text = '1'::text)) > While running, this query produces 100% iowait usage on its processor and takes a ungodly amount of time (about an hour). This plan looks fairly reasonable if the rowcount estimates are accurate. Have you ANALYZEd the table lately? You might need to bump up the statistics target for the msg_log_time column to improve the quality of the estimates. It would be useful to see EXPLAIN ANALYZE results too (yes I know it'll take you an hour to get them...) regards, tom lane