Received: from sss.pgh.pa.us (sss.pgh.pa.us [209.114.132.154]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f18IpBx28886; Thu, 8 Feb 2001 13:51:11 -0500 (EST) (envelope-from tgl@sss.pgh.pa.us) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.11.1/8.11.1) with ESMTP id f18Iov912437; Thu, 8 Feb 2001 13:50:57 -0500 (EST) To: Brice Ruth cc: Stephan Szabo , pgsql-general@postgresql.org, pgsql-sql@postgresql.org Subject: Re: [SQL] Query never returns ... In-reply-to: <3A82CEB1.764160D5@webprojkt.com> References: <3A82CEB1.764160D5@webprojkt.com> Comments: In-reply-to Brice Ruth message dated "Thu, 08 Feb 2001 10:52:00 -0600" Date: Thu, 08 Feb 2001 13:50:57 -0500 Message-ID: <12434.981658257@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200102/403 X-Sequence-Number: 4279 Brice Ruth writes: > As for vacuum analyze - prior to running into these problems, I deleted > all data from the database (using delete from ) and then ran > vacuumdb -a, after which I loaded the data into the tables using 'copy > ... from' - there have been no updates to the database since then - > merely selects. That was the wrong order to do things in :-(. The VACUUM ANALYZE posted statistics showing all your tables as empty, and the planner is now faithfully choosing plans that are good for tiny tables --- ie, minimal startup cost and don't worry about per-tuple cost. There has been some talk of having stats automatically updated by COPY, but right now it doesn't happen. So the correct procedure is to do a VACUUM ANALYZE on a table *after* you do any sizable data additions. BTW, people have occasionally stated on the list that you need to redo VACUUM ANALYZE after adding/dropping indexes, but that's not true, at least not in the present state of the world. VACUUM ANALYZE only posts stats about the data in the table(s). The planner always looks at the current set of indices for a table, together with the last-posted data statistics, to choose a plan. regards, tom lane