X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 309519DC835 for ; Mon, 9 Jan 2006 14:56:54 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 81073-08 for ; Mon, 9 Jan 2006 14:56:53 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 98AFF9DC814 for ; Mon, 9 Jan 2006 14:56:51 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id k09IuowC006915; Mon, 9 Jan 2006 13:56:50 -0500 (EST) To: Alessandro Baretta cc: Matteo Beccati , pgsql-performance@postgresql.org Subject: Re: 500x speed-down: Wrong query plan? In-reply-to: <43C2B06B.4050506@barettadeit.com> References: <43C26A5F.7040702@barettadeit.com> <43C27AFA.7060604@beccati.com> <43C28DEA.60801@barettadeit.com> <6719.1136832065@sss.pgh.pa.us> <43C2B06B.4050506@barettadeit.com> Comments: In-reply-to Alessandro Baretta message dated "Mon, 09 Jan 2006 19:50:19 +0100" Date: Mon, 09 Jan 2006 13:56:50 -0500 Message-ID: <6914.1136833010@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.076 required=5 tests=[AWL=0.076] X-Spam-Score: 0.076 X-Spam-Level: X-Archive-Number: 200601/66 X-Sequence-Number: 16544 Alessandro Baretta writes: > Tom Lane wrote: >> I'm curious to see how many rows the planner thinks this will produce, >> and whether it will use the index or not. > dmd-freerp-1-alex=# EXPLAIN ANALYZE SELECT * FROM articolo WHERE > articolo.xdbs_modified > '2006-01-08 18:25:00+01'; > QUERY PLAN > ------------------------------------------------------------------------------------------------------------------------------------------- > Index Scan using articolo_modified_index on articolo (cost=0.00..3914.91 > rows=17697 width=653) (actual time=0.032..0.032 rows=0 loops=1) > Index Cond: (xdbs_modified > '2006-01-08 18:25:00'::timestamp without time zone) > Total runtime: 0.150 ms > (3 rows) Well, there's your problem: 17697 rows estimated vs 0 actual. With a closer row estimate it would've probably done the right thing for the join problem. How many rows are really in the table, anyway? Could we see the pg_stats row for articolo.xdbs_modified? regards, tom lane