pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Michael Richards <michael@fastmail.ca>
Cc: pgsql-sql@postgresql.org
Cc: pgsql-bugs@postgresql.org
Subject: Re: [SQL] Index selection on a large table
Date: Tue, 25 Jul 2000 19:30:39 -0400
Message-ID: <8873.964567839@sss.pgh.pa.us> (raw)
In-Reply-To: <397E1CCA.000017.47769@frodo.searchcanada.ca>
References: <397E1CCA.000017.47769@frodo.searchcanada.ca>

"Michael Richards" <michael@fastmail.ca> writes:
> The following query yeilds the questionable query plan:

> explain select * from logins where ip='38.30.141.44';
> NOTICE:  QUERY PLAN:
> Seq Scan on logins  (cost=0.00..25248.51 rows=11602 width=48)

If there really were 11602 matching rows, the seq scan likely would be
the way to go.  So the issue here is poor selectivity estimation.

You said you did a VACUUM, but you didn't mention if you'd ever done
a VACUUM ANALYZE.  That looks to me like it's using the default 1%
selectivity estimate, which is what you'd get if you hadn't ever
done an ANALYZE.

If you have done one, what do you get from

select attname,attdisbursion,s.*
from pg_statistic s, pg_attribute a, pg_class c
where starelid = c.oid and attrelid = c.oid and staattnum = attnum
and relname = 'logins';

?

			regards, tom lane



view thread (2+ messages)

Message-ID: <8873.964567839@sss.pgh.pa.us>
Permalink:  ../8873.964567839@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/8873.964567839@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, michael@fastmail.ca, pgsql-bugs@postgresql.org
  Subject: Re: [SQL] Index selection on a large table
  In-Reply-To: <8873.964567839@sss.pgh.pa.us>
  References: <397E1CCA.000017.47769@frodo.searchcanada.ca> <8873.964567839@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox