Skip site navigation (1) Skip section navigation (2)

Re: help required in design of database

From: Markus Schaber <schabi(at)logix-tt(dot)com>
To: david drummard <vijayspam(at)gmail(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: help required in design of database
Date: 2006-02-13 11:49:15
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-performance
Hi, David,

david drummard wrote:

> 1) create a new table every time a new feed file comes in. Create table
> with indexes. Use the copy command to dump the data into the table.

Its faster to obey the following order:

- Create the table
- COPY the data into the table
- Create the indices
- ANALYZE the table.

and probably CLUSTER the table on the most-used index, between index
creation and ANALYZE. You also might want to increase the statistics
target on some columns before ANALYZE, depending on your data.

> 2) rename the current table to some old table name and rename the new
> table to current table name so that applications can access them directly.

You can also use a view, and then use CREATE OR REPLACE VIEW to switch
between the tables.

But two table renames inside a transaction should do as well, and
shorten the outage time, as with the transaction encapsulation, no
external app should see the change inside their transaction.


Markus Schaber | Logical Tracking&Tracing International AG
Dipl. Inf.     | Software Development GIS

Fight against software patents in EU!

In response to

pgsql-performance by date

Next:From: Tim JonesDate: 2006-02-13 16:21:58
Subject: Re: joining two tables slow due to sequential scan
Previous:From: PFCDate: 2006-02-13 08:55:20
Subject: Re: 10+hrs vs 15min because of just one index

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group