X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id A3ABED1B531 for ; Mon, 5 Jan 2004 19:06:55 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 38276-10 for ; Mon, 5 Jan 2004 15:06:05 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id F140BD1B478 for ; Mon, 5 Jan 2004 15:05:49 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id i05J5m19020541; Mon, 5 Jan 2004 14:05:48 -0500 (EST) To: David Teran Cc: Shridhar Daithankar , pgsql-performance@postgresql.org Subject: Re: optimizing Postgres queries In-reply-to: References: <4B0023AC-3F72-11D8-B3EB-000A95A6F0DC@cluster9.com> <200401051705.55120.shridhar_daithankar@myrealbox.com> <64C8DBBA-3F77-11D8-A528-000A95A6F0DC@cluster9.com> <200401051740.05006.shridhar_daithankar@myrealbox.com> <3796212E-3F79-11D8-A528-000A95A6F0DC@cluster9.com> <9966.1073316152@sss.pgh.pa.us> <9CC6A792-3FAF-11D8-A528-000A95A6F0DC@cluster9.com> <16230.1073328760@sss.pgh.pa.us> Comments: In-reply-to David Teran message dated "Mon, 05 Jan 2004 20:02:01 +0100" Date: Mon, 05 Jan 2004 14:05:48 -0500 Message-ID: <20540.1073329548@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200401/47 X-Sequence-Number: 5222 David Teran writes: > explain result from second query: > Seq Scan on "KEY_VALUE_META_DATA" t0 (cost=0.00..2671.16 rows=931 width > =1068) (actual time=122.669..172.179 rows=25 loops=1) > Filter: (("ID_VALUE" = 21094) OR ("ID_VALUE" = 21103)) The problem is evidently that the row estimate is so far off (931 estimate vs 25 actual). Have you done ANALYZE or VACUUM ANALYZE on this table recently? If you have, I'd be interested to see the pg_stats row for ID_VALUE. It might be that you need to increase the statistics target for this table. regards, tom lane