pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PFC <lists@boutiquenumerique.com>
To: arnaulist@andromeiberica.com
To: pgsql-performance@postgresql.org
Subject: Re: Advise about how to delete entries
Date: Fri, 02 Sep 2005 18:47:21 +0200
Message-ID: <op.swhh87t5th1vuj@localhost> (raw)
In-Reply-To: <43183AC9.1060704@andromeiberica.com>
References: <43183AC9.1060704@andromeiberica.com>


>     "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.



view thread (6+ messages)  latest in thread

Message-ID: <op.swhh87t5th1vuj@localhost>
Permalink:  ../op.swhh87t5th1vuj@localhost/
Also on:    postgresql.org/message-id/op.swhh87t5th1vuj@localhost

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: lists@boutiquenumerique.com, arnaulist@andromeiberica.com
  Subject: Re: Advise about how to delete entries
  In-Reply-To: <op.swhh87t5th1vuj@localhost>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox