X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 77DDA8BA1D9 for ; Tue, 15 Feb 2005 20:16:28 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 10193-10 for ; Tue, 15 Feb 2005 20:16:24 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 917598BA310 for ; Tue, 15 Feb 2005 20:16:24 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.13.1/8.13.1) with ESMTP id j1FKGJRF039680 for ; Tue, 15 Feb 2005 20:16:21 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.13.1/8.13.1/Submit) id j1FJFwW5027386 for pgsql-performance@postgresql.org; Tue, 15 Feb 2005 19:15:58 GMT (envelope-from news) From: "lcham02" X-Newsgroups: pgsql.performance Subject: disagreeing query planners Date: 15 Feb 2005 11:15:55 -0800 Organization: http://groups.google.com Lines: 33 Message-ID: <1108494955.402264.279020@l41g2000cwc.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Complaints-To: groups-abuse@google.com User-Agent: G2/0.2 Complaints-To: groups-abuse@google.com Injection-Info: l41g2000cwc.googlegroups.com; posting-host=65.77.250.21; posting-account=I-Krjg0AAACq3z4k5QcewfiQmSmcyykp To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Archive-Number: 200502/247 X-Sequence-Number: 10576 With three databases running the same query, I am receiving greatly differing results from 2 of the query planners. -db2 and db3 are slonied copies of db1. The servers have identical postgresql.conf files but the server hardware differs. -all appropriate columns are indexed -vacuum analyze is run nightly on all dbs Here is a simplified version of the query: ------------------------------------------------------------------------ EXPLAIN ANALYZE SELECT COUNT(DISTINCT(m_object_paper.id)) FROM m_object_paper, m_assignment, m_class, r_comment_rubric_user_object WHERE m_object_paper.assignment=m_assignment.id AND m_assignment.class=m_class.id AND m_class.account = 36123 AND m_object_paper.id = r_comment_rubric_user_object.objectid; ------------------------------------------------------------------------ db1 displays a concise query plan of nested loops and index scans executing in 85 ms. However, db2's query plan consists of sequential scans and takes 3500 ms to complete. The strange part is this. Last week, db1 and db3 were in agreement and executing the more efficient plan. Now, db3 is in agreement with db2 with the less efficient, slower plan. Are we missing something, what could cause this disagreement? Thanks