Re: Need help with upsert - Mailing list pgsql-general

From Vincent Veyron
Subject Re: Need help with upsert
Date
Msg-id 1386192580.2550.14.camel@asus-1001PX.home
Whole thread Raw
In response to Need help with upsert  (Eric Lamer <eric@phoenixsecure.com>)
List pgsql-general
Le mercredi 04 décembre 2013 à 17:48 +0000, Eric Lamer a écrit :

>
>
>   Each day I want to copy the last 7 days into one table so I have one
> table with the last 7 days of logs.
>
>
>
>   So I want to copy the data from 7 tables into 1.  If the row does
> not exist I just insert and if the row already exist I just update the
> sum (existing sum + new sum).
>

Unless you have a specific reason not to, ISTM you could make your life
_much_ easier with just one table and a date column?


>
>
>   Public.test is the table I use for the last 7 days logs.
>
>   daily.daily_20131202 is table for 1 day.
>
>   I will run this command 7 times with different daily table.
>

> Also, is there an easier way to do that?
>

I would just insert all rows into one big table with a date field, and
then make a select count() with the appropriate where clause on the date
field and group by clause.


--
                                        Salutations, Vincent Veyron

Legal cases, contracts and insurance claims management
http://libremen.com




pgsql-general by date:

Previous
From: Scott Marlowe
Date:
Subject: Re: how much disk space does a VACUUM FULL take?
Next
From: Merlin Moncure
Date:
Subject: Re: Postgres 9.3 read block error went into recovery mode