B
B
beduin012015-06-18 15:12:59
PostgreSQL
beduin01, 2015-06-18 15:12:59

Why is postgres deleting data so slow?

There is a table with such a structure (I post the generated html) rghost.ru/6WG8l7PMN (please don't kick me, I didn't design it).
It is necessary to delete all data from there before 2014 and after 2015. Here is the request itself:

DELETE FROM
request.request
WHERE request.agreed <=  '2014-01-01' 
OR request.agreed >=  '2015-01-01'

The problem is that the removal is extremely slow. 2 records are deleted one and a half seconds! And how many will delete several thousand records?
Why is everything so slow? PG version 9.1, is there a way to speed it up? So far, the task is precisely to delete the data one-time from there and that's it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2015-06-24
@liff

make an index across the agreed field or a func-th index.
If there is a lot of data, partitioning will help.
PS I did not look at the database scheme.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question