Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id AEA891337B58 for ; Tue, 15 Mar 2011 14:07:27 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 99758-03 for ; Tue, 15 Mar 2011 17:07:18 +0000 (UTC) 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 94B661337BB7 for ; Tue, 15 Mar 2011 14:07:18 -0300 (ADT) 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 p2FH7GX8000433; Tue, 15 Mar 2011 13:07:16 -0400 (EDT) To: "Robert Brewer" cc: pgsql-bugs@postgresql.org Subject: Re: SELECT '(1, nan, 3)'::cube; In-reply-to: References: Comments: In-reply-to "Robert Brewer" message dated "Tue, 15 Mar 2011 09:08:42 -0700" Date: Tue, 15 Mar 2011 13:07:16 -0400 Message-ID: <432.1300208836@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201103/222 X-Sequence-Number: 29732 "Robert Brewer" writes: > I'm working on a hypercube implementation in Postgres using contrib/cube > and need to insert 80,000 rows in one go from Python. Doing so with > INSERT, even multiple statements in one call, is pretty slow. I've been > investigating if using COPY is faster. It is, but there's a problem: > some of the cubes should include NaN. Writing: > INSERT INTO foo (coords) VALUES (cube(ARRAY[1, 'nan', 3]::float[])); > ...works fine. But I can't find the magic incantation to do the same > thing using COPY FROM. cube_in doesn't accept either 'nan' or 'inf'. It's probably a bug that you can get those things into a cube value via cube(float8[]). Or we could see about upgrading the datatype to allow them, but that would require looking at all its operations not just cube_in. It seems pretty likely to me that there are some other things in that module that won't behave sanely with NaN, because the original author clearly never thought about it. I'd suggest rethinking your design to avoid needing NaN in a cube. regards, tom lane