Sheldor
Sheldor

Reputation: 310

What is the safe limit for the number of rows in postgresql?

I have a cron job that fires a query every three minutes. With each firing, data is entered into my db. So my database keeps on growing after each interval. However I am only interested in the latest row. Is it safe? Will postgresql truncate oldest entries automatically?

Upvotes: 0

Views: 485

Answers (1)

Gurmokh
Gurmokh

Reputation: 2091

If you post the gist of your cron job you could get a better answer.

If its a direct insert, execute a truncate before hand to delete the old unwanted data. Delete is also possible, but you will end up with a lot of dead tuples and you will need to vacuum the table on a regular basis.

update is a good option but it depends on how much of the data is static and how much is not. eg. if you repeat values in any columns then go for update. This will also be subject to dead tuples and vacuuming.

if you are loading from an external source, eg csv, json, xml there are methods to overwrite existing data automatically. pg_loader may be an option here.

Upvotes: 1

Related Questions