Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 2C07664FDFF for ; Tue, 2 Dec 2008 11:51:19 -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 40501-01 for ; Tue, 2 Dec 2008 11:51:15 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smtp-out.neti.ee (smtp-out.neti.ee [194.126.126.44]) by mail.postgresql.org (Postfix) with ESMTP id 274B96502EB for ; Tue, 2 Dec 2008 11:51:11 -0400 (AST) Received: from localhost (localhost [127.0.0.1]) by MXR-4.estpak.ee (Postfix) with ESMTP id F03A72402B0; Tue, 2 Dec 2008 17:51:07 +0200 (EET) X-Virus-Scanned: Debian amavisd-new at Relay4.estpak.ee Received: from smtp-out.neti.ee ([127.0.0.1]) by localhost (MXR-4.estpak.ee [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tNHwbqbJ4zoB; Tue, 2 Dec 2008 17:51:07 +0200 (EET) Received: from Relayhost2.neti.ee (Relayhost2 [88.196.174.142]) by MXR-4.estpak.ee (Postfix) with ESMTP id 8D3F924010A; Tue, 2 Dec 2008 17:51:07 +0200 (EET) X-SMTP-Auth-NETI-Businesmail: no Received: from andrusnotebook (unknown [195.50.198.194]) by Relayhost2.neti.ee (Postfix) with SMTP id D39171FD948; Tue, 2 Dec 2008 17:51:06 +0200 (EET) Message-ID: <72246E216337406EAD285F5A45533672@andrusnotebook> From: "Andrus" To: , "PFC" References: <95776070DDC841978DF8335DCF59D6BB@andrusnotebook> In-Reply-To: Subject: Re: analyzing intermediate query Date: Tue, 2 Dec 2008 17:50:53 +0200 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="utf-8"; reply-type=response Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Windows Mail 6.0.6001.18000 X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6001.18049 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: 200812/15 X-Sequence-Number: 32051 > Oh, I just thought about something, I don't remember in which version it > was added, but : > > EXPLAIN ANALYZE SELECT sum(column1) FROM (VALUES ...a million > ntegers... ) AS v > > Postgres is perfectly happy with that ; it's either a bit slow (about 1 > second) or very fast depending on how you view things... I tried in 8.1.4 select * from (values (0)) xx but got ERROR: syntax error at or near ")" SQL state: 42601 Character: 26 Even if this works this may be not solution: I need to apply distinct to temporary table. Temporary table may contain duplicate values and without DISTINCT join produces invalid result. Temporary table itself is created from data from server tables, it is not generated from list. I can use SELECT dok.* FROM dok WHERE dokumnr IN (SELECT dokumnr FROM temptbl) but this seems never use bitmap index scan in 8.1.4 Sadly, creating second temporary table from first temporary table specially for this query seems to be only solution. When materialized row count will be added so that statistics is exact and select count(*) from tbl runs fast ? Andrus.