Received: from sd.tpf.co.jp (sd.tpf.co.jp [210.161.239.34]) by postgresql.org (8.11.3/8.11.4) with SMTP id g099fYB59664 for ; Wed, 9 Jan 2002 04:41:34 -0500 (EST) (envelope-from Inoue@tpf.co.jp) Received: (qmail 6391 invoked from network); 9 Jan 2002 09:41:34 -0000 Received: from unknown (HELO viscomail.tpf.co.jp) (100.0.0.108) by sd2.tpf-fw-c.co.jp with SMTP; 9 Jan 2002 09:41:34 -0000 Received: from tpf.co.jp (3dgateway1 [126.0.1.60]) by viscomail.tpf.co.jp (8.8.8+Sun/8.8.8) with ESMTP id SAA05403; Wed, 9 Jan 2002 18:41:31 +0900 (JST) Message-ID: <3C3C1132.E51307CF@tpf.co.jp> Date: Wed, 09 Jan 2002 18:45:22 +0900 From: Hiroshi Inoue X-Mailer: Mozilla 4.73 [ja] (Windows NT 5.0; U) X-Accept-Language: ja MIME-Version: 1.0 To: Daniel Kalchev CC: Tom Lane , pgsql-hackers@postgresql.org Subject: Re: again on index usage References: <200201090745.JAA15141@dcave.digsys.bg> Content-Type: text/plain; charset=iso-2022-jp Content-Transfer-Encoding: 7bit X-Archive-Number: 200201/376 X-Sequence-Number: 17415 Daniel Kalchev wrote: > > >>>Tom Lane said: > > Daniel Kalchev writes: > > > Same result (sorry, should have included this originally): > > > > >>> If you say "set enable_seqscan to off", does that change the plan? > > > > > Aggregate (cost=100359.71..100359.71 rows=1 width=8) > > > -> Index Scan using iplog_gate200112_ipdate_idx on iplog_gate200112 > > > (cost=0.00..100217.52 rows=56873 width=8) > > > > So, what we've got here is a difference of opinion: the planner thinks > > that the seqscan will be faster. How many rows are actually selected > > by this WHERE clause? How long does each plan actually take? > > > > regards, tom lane > > 3-5 minutes with sequential scan; 10-15 sec with index scan. The query returns > 4062 rows. Out of ca 1700000 rows. > > With only the datetime constraints (which relates to the index), the number of > rows is 51764. The planner estimates 56873 rows. It seems not that bad. A plausible reason is your table is nearly clustered as to ipdate. regards, Hiroshi Inoue