Received: from news.tht.net (news.hub.org [216.126.91.242]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f0TGxoq08778 for ; Mon, 29 Jan 2001 11:59:50 -0500 (EST) (envelope-from news@news.tht.net) Received: (from news@localhost) by news.tht.net (8.11.1/8.11.1) id f0TGVXT77699 for pgsql-sql@postgresql.org; Mon, 29 Jan 2001 11:31:33 -0500 (EST) (envelope-from news) From: "Mark A. Summers" X-Newsgroups: comp.databases.postgresql.sql Subject: Re: SQL Help Date: Mon, 29 Jan 2001 11:29:02 -0500 Organization: IRT Lines: 37 Message-ID: <9545t5$2bs0$1@news.tht.net> References: X-Complaints-To: scrappy@hub.org X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 To: pgsql-sql@postgresql.org X-Archive-Number: 200101/434 X-Sequence-Number: 1110 I am loser -- I didn't realize there was analyze option on vacuum -- I created another index on Publisher code -- Now it smokes thanks Mark Summers "Stephan Szabo" wrote in message news:Pine.BSF.4.21.0101261746560.98620-100000@megazone23.bigpanda.com... > > On Fri, 26 Jan 2001, Mark A. Summers wrote: > > > I am having trouble with the following query taking forever: > > ----- > > SELECT * FROM ret108108_00, product > > WHERE ret108108_00."isbn" = product."Item1" > > > > AND product."SuperCategory" = '1' > > AND product."PublisherCode" = 'ZON' > > ORDER BY ret108108_00.qty DESC LIMIT 100 > > ---- > > The problem is the second AND -- if I take this out it runs fine -- is there > > any way to optimize it ? I had a similar problem with just Category so I > > created a new field in the product file called FullCat which combined > > SuperCategory and Category and thus eliminating the 2nd AND clause -- and > > that fixed it -- I just didn't want to do the same thing with Publisher. > > Before I tried to index Category, SuperCategory ... nothing seemed to help > > Have you run a VACUUM ANALYZE on the table? And what does > EXPLAIN show for the query? >