Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id 0D7594766FD for ; Tue, 25 Jun 2002 16:22:21 -0400 (EDT) Mailbox-Line: From emayo@pozicom.net Tue Jun 25 16:22:21 2002 Received: from news.hub.org (news.hub.org [64.49.215.80]) by postgresql.org (Postfix) with ESMTP id 2FF06475A71 for ; Tue, 25 Jun 2002 15:25:58 -0400 (EDT) Received: by news.hub.org (Postfix, from userid 8) id C66CB381911; Tue, 25 Jun 2002 15:25:32 -0400 (EDT) From: "Eric" X-Newsgroups: comp.databases.postgresql.sql Subject: 2 Selects 1 is faster, why? Date: Tue, 25 Jun 2002 15:25:32 -0400 Organization: Hub.Org Networking Services (http://www.hub.org) Lines: 44 Message-ID: X-Complaints-To: news@hub.org X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 To: pgsql-sql@postgresql.org X-Spam-Status: No, hits=-0.2 required=5.0 tests=SUBJ_ENDS_IN_Q_MARK,FROM_NAME_NO_SPACES version=2.30 X-Spam-Level: X-Archive-Number: 200206/344 X-Sequence-Number: 8309 If I perform the following 2 selects, the first one is EXTREMELY slow where the 2nd one is very fast. (1) Slow select o.orderid, ol.itemcode, ol.itemname from orders o, orlines ol where o.orderid = '1234' and ol.orderid = o.orderid; (2) VERY FAST select o.orderid, ol.itemcode, ol.itemname from orders o, orlines ol where o.orderid = '1234' and ol.orderid = '1234' Why would 2 be so much faster? I have ran the EXPLAIN on this and index scans are being used. NOTE: The actual queries return more information than this, but the fundamental change shown above seems to give me the instant response I am looking for. (1) takes about 60 seconds to run and (2) takes 3-5 seconds to run. Thanks, Eric