pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Shridhar Daithankar <shridhar_daithankar@persistent.co.in>
To: pgsql-general@postgresql.org
Cc: pgsql-performance@postgresql.org
Subject: Re: Performance hit of foreign key constraints?
Date: Wed, 23 Jul 2003 15:24:01 +0530
Message-ID: <3F1EA891.16257.43E80B6@localhost> (raw)
In-Reply-To: <3F1E339C.7010304@mega-bucks.co.jp>

On 23 Jul 2003 at 16:05, Jean-Christian Imbeault wrote:

> I have a database which is constantly being written to. A web server's 
> log file (and extras) is being written to it. There are no deletions or 
> updates (at least I think so :).
> 
> As the web traffic increases so will the write intensity.
> 
> Right now the database tables have no foreign keys defined even though 
> there are foreign keys. The code that inserts into the DB is simple 
> enough (now) that we can make sure that nothing is inserted if the 
> corresponding fk does not exist and that all fk checks pass.
> 
> I want to add foreign key constraints to the table definitions but I am 
> worried that it might be a big performance hit. Can anyone tell me how 
> much of a performance hit adding one foreign key constraint to one field 
> in a table will roughly be?
> 
> Also, for a DB that is write-intensive and rarely read, what are some 
> things I can do to increase performance? (Keeping in mind that there is 
> more than on DB on the same pg server).

1. Insert them in batches. Proper size of transactions can speed the write 
performance heavily.
2. What kind of foreign keys you have? It might be possible to reduce FK 
overhead if you are checking against small number of records.
3. Tune your hardware for write performance like getting a good-for-write RAID. 
I forgot which performs which for read and write.
4. Tune WAL and move it to separate drive. That should win you some 
performance.

HTH

Bye
 Shridhar

--
Beauty:	What's in your eye when you have a bee in your hand.




view thread (4+ messages)  latest in thread

Message-ID: <3F1EA891.16257.43E80B6@localhost>
Permalink:  ../3F1EA891.16257.43E80B6@localhost/
Also on:    postgresql.org/message-id/3F1EA891.16257.43E80B6@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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: shridhar_daithankar@persistent.co.in, pgsql-general@postgresql.org
  Subject: Re: Performance hit of foreign key constraints?
  In-Reply-To: <3F1EA891.16257.43E80B6@localhost>
  References: <3F1E339C.7010304@mega-bucks.co.jp> <3F1EA891.16257.43E80B6@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