Received: from localhost (unknown [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id BF0059FB87A for ; Fri, 5 Oct 2007 12:02:05 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 01439-10 for ; Fri, 5 Oct 2007 12:02:02 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.168]) by postgresql.org (Postfix) with ESMTP id 370FB9F9955 for ; Fri, 5 Oct 2007 12:02:00 -0300 (ADT) Received: by ug-out-1314.google.com with SMTP id j3so556354ugf for ; Fri, 05 Oct 2007 08:01:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=6xp3dMyoahNSNYvDuAhgttz0fY6vsKssDtmcDmxrocY=; b=mEEVPOVfox9NOccysjX0AZEwMYm5rlH1pQknKCh378nhMvArtKsaL+DMV428YUawQJCRWAa4zzE513tDRAbyZ8un3uUZ/WFwDiXuTyauZKrunrYzwuFXuq9Mo+x5lxvzN0VvcnNRUsEM//n0S3Vy6SXflqDFYYtf+1USLh0UUQo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=h340QDNdOPGAg6xVKM4YAIq/buS5bd38LWniCiZOBX7k5GbHbI5+8ZyOUSt4lKtXMrgB8fLWqJR1cp67CmNpT9rXgQdfjjSBwmF9wMRbxj6zX1FFMIPf5kkDgV/lkkkzi4ISUk683WMH7pO4IpZkk3J7Z4akBdQt65F4FSC/oWs= Received: by 10.67.31.5 with SMTP id i5mr3378880ugj.1191596519058; Fri, 05 Oct 2007 08:01:59 -0700 (PDT) Received: by 10.66.220.7 with HTTP; Fri, 5 Oct 2007 08:01:59 -0700 (PDT) Message-ID: Date: Fri, 5 Oct 2007 10:01:59 -0500 From: "Scott Marlowe" To: "=?ISO-8859-1?Q?Cl=E1udia_Macedo_Amorim?=" Subject: Re: Problems with + 1 million record table Cc: pgsql-performance@postgresql.org In-Reply-To: <002001c8075c$c9736df0$9fc8a8c0@pcserver.pcinformatica.com.br> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <002001c8075c$c9736df0$9fc8a8c0@pcserver.pcinformatica.com.br> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200710/56 X-Sequence-Number: 27078 On 10/5/07, Cl=E1udia Macedo Amorim w= rote: > > I'm new in PostGreSQL and I need some help. > > I have a table with ~2 million records. Queries in this table are too slo= w > and some are not completed. > I think it must be a simple question to solve but, I'm trying without > success. I'm worried because next week I will need to work with tables > with ~100 million records. > > I'm using: > O.S.: Windows XP; > PostgreSQL 8.2; > Index type: btree. > > I have 2 GB of RAM. > > POSTGRESQL XXX.LOG: > > <2007-10-05 09:01:42%SELECT> LOG: could not send data to client: Unknown > winsock error 10061 > <2007-10-05 09:03:03%idle> LOG: could not receive data from client: Unkn= own > winsock error 10061 > <2007-10-05 09:03:03%idle> LOG: unexpected EOF on client connection This looks like your client is dying on receiving too much data. You can either try to fix the client to handle more data, which isn't the best way to proceed, or you can retrieve your data with a cursor a chunk at a time. > PSQLODBC.LOG: > [13236.501]CONN ERROR: func=3DSC_execute, desc=3D'(null)', errnum=3D109, > errmsg=3D'Out of memory while reading tuples.' Assuming this is the client side error, yes, you're simply reading too many rows at once. > POSTGRESQL.CONF: > shared_buffers =3D 512MB # min 128kB or max_connections*16kB Reasonable for a machine with 2 G ram. > work_mem =3D 256MB # min 64kB If and only if you have one or two users, this is ok. Otherwise it's a bit high. Take a look at cursors, here's the declare ref page: http://www.postgresql.org/docs/8.2/static/sql-declare.html