Received: from p1.selectacast.net (p1.selectacast.net [206.41.1.251]) by mail.postgresql.org (8.11.3/8.11.1) with ESMTP id f2K25aN89800 for ; Mon, 19 Mar 2001 21:05:36 -0500 (EST) (envelope-from jks@selectacast.net) Received: from selectacast.net (IDENT:jks@d1 [209.219.91.66]) by p1.selectacast.net (8.9.3/8.9.3) with ESMTP id VAA17627; Mon, 19 Mar 2001 21:05:26 -0500 Message-ID: <3AB6BAE6.5DE53B8D@selectacast.net> Date: Mon, 19 Mar 2001 21:05:26 -0500 From: Joseph Shraibman Organization: Xtenit, Inc. http://www.xtenit.com X-Mailer: Mozilla 4.76 [en] (X11; U; Linux 2.4.2 i686) X-Accept-Language: en MIME-Version: 1.0 To: Gerald Gutierrez CC: pgsql-sql@postgresql.org Subject: Re: VACUUM kills Index Scans ?! References: <5.0.2.1.0.20010315113535.0282b750@kalador.com> <5.0.2.1.0.20010315113535.0282b750@kalador.com> <5.0.2.1.0.20010315125737.0282b9c0@kalador.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200103/383 X-Sequence-Number: 2051 Gerald Gutierrez wrote: > > >There is an undocumented little factoid here: CREATE INDEX will update > >(some of) the planner stats, but only if it finds some data in the > >table. CREATE INDEX on an empty table leaves the initial default > >numbers alone. This may be contributing to your confusion, but it was > >deemed necessary ... > > I understand now; it makes sense. I'll be using a number of tables that are > initially very small, perhaps 5 or 10 records. But I expect that the tables > will grow very quickly to several tens (or hundreds) of thousands of > records. It seems reasonable to me that the table should then be set up to > use index scan right from the beginning so that as the table grows the > index scan will become more useful. Thus, the correct sequence for me is > probably: > > > CREATE TABLE > > CREATE INDEX > > load data > no, the correct sequence is to create the index last, which will create statistics that will tell postgres if it really wants to use an index or not. Don't try and second guess postgres. Even better do a VACUUM ANALYZE. -- Joseph Shraibman jks@selectacast.net Increase signal to noise ratio. http://www.targabot.com