Re: help required in design of database

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

HTH,
Markus


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

Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org


[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux