Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 57445D33CC1 for ; Tue, 12 Jun 2012 23:38:08 -0300 (ADT) Received: from mail-pb0-f46.google.com ([209.85.160.46]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SedTC-0000aq-Ug for pgsql-sql@postgresql.org; Wed, 13 Jun 2012 02:38:07 +0000 Received: by pbbrp8 with SMTP id rp8so1644878pbb.19 for ; Tue, 12 Jun 2012 19:37:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=GsYtVB64CYymOLA2CfR5UQU6v2DsP8PCIUM8IZPlt9k=; b=oAPYwaI1SrlLswjV5YT8Z+Io+9r12krMV1/H9PdmLtlg7VUvGIm64sNmr8QoSobCW4 iCHq941vbjr5v4U6W5w7M6oe/39uYaUVtWU9Syl7NXs/BZ1HwKU8CSQ54lbfoj0sqPKK YsgpgujwvaN8/3gfRh9y8YegFO7C5R1e3DyHY0a9wP0HwT0NfIm3r1Cozj9C7Z3KJp6G R63d/K2xRV9JNvA3R//PHNX7dmO42Wm86nZ58G6VFTQVs0D6Hxl6TyboQEhmqZwUP141 IDzNfKyhIZtXZ/BPn5n0H3nmirfqb16Cx7lR0i/WAHPVdLox895rD8Mx52hw9bnBYXgs oCcQ== Received: by 10.68.232.201 with SMTP id tq9mr45089442pbc.70.1339555074055; Tue, 12 Jun 2012 19:37:54 -0700 (PDT) Received: from ayaki.localdomain (office1.postnewspapers.com.au. [150.101.171.128]) by mx.google.com with ESMTPS id jp3sm4060319pbc.7.2012.06.12.19.37.51 (version=SSLv3 cipher=OTHER); Tue, 12 Jun 2012 19:37:53 -0700 (PDT) Message-ID: <4FD7FCFD.6010900@ringerc.id.au> Date: Wed, 13 Jun 2012 10:37:49 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120605 Thunderbird/13.0 MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Re: Partitioned Tables References: <20120613000545.GM19474@slacker.ja10629.home> In-Reply-To: <20120613000545.GM19474@slacker.ja10629.home> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQkouzap8ylk5dn1WqeMTabvHWXZ1iq8ltht/khIXfbAgmna6KmwPUAxNwY6zJusnBGbf4QZ X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201206/32 X-Sequence-Number: 36686 On 06/13/2012 08:05 AM, Wayne Cuddy wrote: > I'm using partitioned tables where a child table is chosen based on a > time stamp. One child table exists for each month. > > I move records from a temp table to the partitioned table via something like > this: > > INSERT INTO parent_table SELECT * FROM temp_table; > > All works well but with when inserting to standard tables the insert > result contains the number of records inserted. I've found that when I > insert into partitioned tables the result is always zero. Are you inserting directly into the partition? Or into the parent table? If you're inserting into the parent, then it's true that no rows were inserted into the parent; a trigger redirected the write into the child table. Pg's handling of partitioning isn't yet sophisticated enough to recognise that those rows got written to a child and thus still appeared in the parent and report that. As a workaround, ignore the insert count for partitioned tables, or insert directly into the appropriate partition(s). -- Craig Ringer