Received: from mail.postgresql.org (webmail.postgresql.org [216.126.85.28]) by mail.postgresql.org (8.11.1/8.11.1) with SMTP id f0R0v5q69273 for ; Fri, 26 Jan 2001 19:57:05 -0500 (EST) (envelope-from pgsql-sql-owner@postgresql.org) 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 f0QJTfq38802 for ; Fri, 26 Jan 2001 14:29:41 -0500 (EST) (envelope-from news@news.tht.net) Received: (from news@localhost) by news.tht.net (8.11.1/8.11.1) id f0QJDP423327 for pgsql-sql@postgresql.org; Fri, 26 Jan 2001 14:13:25 -0500 (EST) (envelope-from news) From: "Mark A. Summers" X-Newsgroups: comp.databases.postgresql.sql Subject: SQL Help Date: Fri, 26 Jan 2001 14:11:45 -0500 Organization: IRT Lines: 23 Message-ID: <94si8l$mos$1@news.tht.net> 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/403 X-Sequence-Number: 1079 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 Any ideas Thanks in advance Mark Summers