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! www.ffii.org www.nosoftwarepatents.org
In response to
pgsql-performance by date
|Next:||From: Tim Jones||Date: 2006-02-13 16:21:58|
|Subject: Re: joining two tables slow due to sequential scan |
|Previous:||From: PFC||Date: 2006-02-13 08:55:20|
|Subject: Re: 10+hrs vs 15min because of just one index|