postgresql - Values missing in postgres serial field -


I run a small site and postgreSQL 8.2.17 (only the version available on my host) to store the data I use In the past few months there were 3 accidents of database system on my server and every time this table was lost in a table with a serial field (primary key). Now 93 IDs are missing.

Tables:

  create table "registry" ("id" serial not zero, "stewid" character different (11), "strxml" text, "intestatus" integer , "Strideorg" character different (11),)  

It is very important to me that all ID values ​​are what you can do to solve this problem?

You can not hope to keep the serial column in the hole

You can apply the inherent key by sacrificing the concurrency, like this:

  create table registry_lest_id (value int tap); Enter in Registry_last_id values ​​(-1); Become a function next_registry_id () $ int contains the int flawless return value of the registry_last_id set value = value + 1 return value $$; Make the table registry (ID int main default defaults next_registry_id (), ...)  

but any code that attempts to insert something on the registry By then the block will end up the other converged transaction and write its data on the disk. This will not limit you to putting more than 125 transactions per second on a 7500rpm disk drive.

Any entry from the Registry will make an interval.

This solution is based on the writings of A. Eilin Mustaine, which is somewhat old.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -