| From: | PFC <lists(at)boutiquenumerique(dot)com> |
|---|---|
| To: | arnaulist(at)andromeiberica(dot)com, pgsql-performance(at)postgresql(dot)org |
| Subject: | Re: Advise about how to delete entries |
| Date: | 2005-09-02 16:47:21 |
| Message-ID: | op.swhh87t5th1vuj@localhost |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Josh Berkus | 2005-09-02 16:50:01 | Re: Massive performance issues |
| Previous Message | Patrick Hatcher | 2005-09-02 16:12:04 | Poor SQL performance |