Re: Need help with upsert

From: Vincent Veyron <vv(dot)lists(at)wanadoo(dot)fr>
To: Eric Lamer <eric(at)phoenixsecure(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Need help with upsert
Date: 2013-12-04 21:29:40
Message-ID: 1386192580.2550.14.camel@asus-1001PX.home
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Merlin Moncure 2013-12-04 21:47:45 Re: Postgres 9.3 read block error went into recovery mode
Previous Message Scott Marlowe 2013-12-04 18:17:31 Re: how much disk space does a VACUUM FULL take?