Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 98A1264FCBE for ; Sat, 22 Nov 2008 14:17:25 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 62015-08 for ; Sat, 22 Nov 2008 14:17:22 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 0389F64FC5C for ; Sat, 22 Nov 2008 14:17:20 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id mAMIHFRV029117; Sat, 22 Nov 2008 13:17:15 -0500 (EST) To: "Michael Thorsen" cc: pgsql-general@postgresql.org Subject: Re: SQL query In-reply-to: <4c8d33a90811212033x5e88177eo7a026b10336c975b@mail.gmail.com> References: <4c8d33a90811212033x5e88177eo7a026b10336c975b@mail.gmail.com> Comments: In-reply-to "Michael Thorsen" message dated "Fri, 21 Nov 2008 22:33:33 -0600" Date: Sat, 22 Nov 2008 13:17:15 -0500 Message-ID: <29116.1227377835@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200811/1149 X-Sequence-Number: 140867 "Michael Thorsen" writes: > ... I gave a simple example above, but the query runs over 2 tables > with about a million entries in each. So I am unable to verify what is > wrong, but I know the count is incorrect as I should not have more than what > is in the user_table. You could easily get a count larger than the number of rows in user_table, if there are rows in user_table that join to multiple rows in the locations table. So look for duplicated data in locations ... regards, tom lane