Re: Advise about how to delete entries
От | PFC |
---|---|
Тема | Re: Advise about how to delete entries |
Дата | |
Msg-id | op.swhh87t5th1vuj@localhost обсуждение исходный текст |
Ответ на | Advise about how to delete entries (Arnau <arnaulist@andromeiberica.com>) |
Ответы |
Re: Advise about how to delete entries
|
Список | pgsql-performance |
> "DELETE FROM statistics_sasme WHERE statistic_id = 9832;" As Michael said, why use a NUMERIC when a bigint is faster and better for your use case, as you only need an integer and not a fixed precision decimal ? Also if you use postgres < 8, the index will not be used if you search on a type different from the column type. So, if your key is a bigint, you should do WHERE statistic_id = 9832::bigint. For mass deletes like this, you should use one of the following, which will be faster : DELETE FROM ... WHERE ID IN (list of values) Don't put the 30000 values in the same query, but rather do 300 queries with 100 values in each. COPY FROM a file with all the ID's to delete, into a temporary table, and do a joined delete to your main table (thus, only one query). EXPLAIN DELETE is your friend.
В списке pgsql-performance по дате отправления: