Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id AF3C9474E42 for ; Tue, 16 Jul 2002 14:52:06 -0400 (EDT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id D3B90D600; Tue, 16 Jul 2002 11:52:05 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id BF5135C02; Tue, 16 Jul 2002 11:52:05 -0700 (PDT) Date: Tue, 16 Jul 2002 11:52:05 -0700 (PDT) From: Stephan Szabo To: Alain Lavigne Cc: Subject: Re: Need help on a troublesome query plan In-Reply-To: Message-ID: <20020716115118.L51289-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200207/245 X-Sequence-Number: 8623 On Tue, 16 Jul 2002, Alain Lavigne wrote: > Index "bld_x1_tb_bus_fact" > Column | Type > -----------------+--------------- > party_id | bigint > bus_fact_typ_cd | character(10) > cont_id | bigint > btree > > With the following query on 50000 records: > > explain > SELECT bld_TB_BUS_FACT.BUS_FACT_ID AS id > FROM bld_TB_BUS_FACT > WHERE bld_TB_BUS_FACT.PARTY_ID=1320677 > AND bld_TB_BUS_FACT.BUS_FACT_TYP_CD='MSG_SENT' > AND bld_TB_BUS_FACT.CONT_ID=786448 > AND bld_TB_BUS_FACT.BUS_FACT_KYWRD ILIKE '%MT-ID=3407979%' > AND bld_TB_BUS_FACT.BUS_FACT_KYWRD ILIKE '%S-ID=1310723%' > limit 1; You'll need to either single quote or explicitly cast the constants you're comparing to the bigint columns.