Re: Huge Data
Richard Huxton <dev@archonet.com>
From: Richard Huxton <dev@archonet.com>
To: Sezai YILMAZ <sezai.yilmaz@pro-g.com.tr>
Cc: pgsql-general@postgresql.org
Date: 2004-01-14T13:18:45Z
Lists: pgsql-general
On Wednesday 14 January 2004 12:39, Sezai YILMAZ wrote: > > select logid, agentid, logbody from log where logid=3000000; At a guess, because logid is bigint, whereas 300000 is taken to be integer. Try ... where logid = 300000::bigint; This is in the FAQ too I think, and is certainly in the archives. Other things you might come across: SELECT max() involves a sequential scan just like count(), you can rewrite it as SELECT target_column FROM my_table ORDER BY target_column DESC LIMIT 1 The config values are very conservative. You will definitely want to tune them for performance. See the articles here for a good introduction: http://www.varlena.com/varlena/GeneralBits/Tidbits/index.php The VACUUM command is used to reclaim unused space, and the ANALYZE command to regenerate statistics. It's worth reading up on both. You can use EXPLAIN ANALYSE <query here> to see the plan that PG uses. I think there's a discussion of it at http://techdocs.postgresql.org/ -- Richard Huxton Archonet Ltd