From: | Jeff Davis <pgsql(at)j-davis(dot)com> |
---|---|
To: | alan <alan(dot)miller3(at)gmail(dot)com> |
Cc: | pgsql-performance(at)postgresql(dot)org |
Subject: | Re: delete/recreate indexes |
Date: | 2011-10-20 02:51:09 |
Message-ID: | 1319079069.16256.42.camel@jdavis |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
On Wed, 2011-10-19 at 08:03 -0700, alan wrote:
> So I thought I’d just run this once (via cron) every morning.
> BEGIN;
> DROP INDEX data_unique;
> UPDATE data SET datum = (data.datum + interval '24 hours');
> CREATE UNIQUE INDEX data_unique ON public.data USING BTREE
> (device, group, datum);
> COMMIT;
>
> But
> 1. it’s taking forever and
> 2. I’m seeing that my disk is filling up real fast.
An unrestricted update will end up rewriting the whole table. It's
advisable to run VACUUM afterward, so that the wasted space can be
reclaimed. What version are you on? Do you have autovacuum enabled?
Also, to take a step back, why do you try to keep the timestamps
changing like that? Why not store the information you need in the record
(e.g. insert time as well as the datum) and then compute the result you
need using a SELECT (or make it a view for convenience)? Fundamentally,
these records aren't changing, you are just trying to interpret them in
the context of the current day. That should be done using a SELECT, not
an UPDATE.
Regards,
Jeff Davis
From | Date | Subject | |
---|---|---|---|
Next Message | Craig Ringer | 2011-10-20 03:34:03 | Re: How many Cluster database on a single server |
Previous Message | Scott Marlowe | 2011-10-20 02:01:42 | Re: disused indexes and performance? |