| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | Marco Catunda <catunda(at)pobox(dot)com> |
| Cc: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: Doesn't use index, why? |
| Date: | 2001-01-04 17:12:18 |
| Message-ID: | 22047.978628338@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Marco Catunda <catunda(at)pobox(dot)com> writes:
> naslog=# explain select * from desconexao where time = '2000-12-01';
> NOTICE: QUERY PLAN:
> Index Scan using time_idx on desconexao (cost=0.00..20.18 rows=5
> width=103)
> naslog=# explain select * from desconexao where time > '2000-12-01';
> NOTICE: QUERY PLAN:
> Seq Scan on desconexao (cost=0.00..19547.71 rows=657958 width=103)
> Why postgresql didn't use the time_idx index? I only changed the
> operator "=" to ">" in clause "where".
Because the '>' condition is much less restrictive (notice the
difference in estimated row counts: 5 versus 657958). Unless the
planner's row count estimates are way off, it very likely *is* faster
to do the second query by sequential scan.
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Nathan Barnett | 2001-01-04 17:26:36 | Index on Date_Trunc |
| Previous Message | Tom Lane | 2001-01-04 17:09:13 | Re: Time Zone Query |