Re: Use of BETWEEN with identical values

From: André Volpato <andre(dot)volpato(at)ecomtecnologia(dot)com(dot)br>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: Use of BETWEEN with identical values
Date: 2009-09-17 21:02:08
Message-ID: 4AB2A3D0.6080508@ecomtecnologia.com.br
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

André Volpato escreveu:
> (...)
>
> (Postgres 8.3.6, Debian Linux 2.6.18-6-amd64)
>
> (...)

> Condition 1:
> # select fat_referencia from bds_contratacao_fatura where
> fat_referencia BETWEEN 200908 AND 200908;
> Index Scan using ibds_contratacao_fatura1 on bds_contratacao_fatura
> (cost=0.00..5.64 rows=1 width=4) (actual time=0.023..79.952
> rows=163689 loops=1)
> Index Cond: ((fat_referencia >= 200908) AND (fat_referencia <= 200908))
> Total runtime: 110.470 ms

> Condition 3:
> # select fat_referencia from bds_contratacao_fatura where
> fat_referencia = 200908;
> Index Scan using ibds_contratacao_fatura1 on bds_contratacao_fatura
> (cost=0.00..4745.07 rows=142940 width=4) (actual time=0.022..77.818
> rows=163689 loops=1)
> Index Cond: (fat_referencia = 200908)
> Total runtime: 108.292 ms
>
> I expect Postgres would give me the same plan in conditions 1 and 3.

And also the core team...

This behaviour is 8.3 related. In 8.4, conditions 1 and 3 results in the
same plan.

--

[]´s,

André Volpato

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Bruce Momjian 2009-09-18 02:29:08 Re: Planner question - "bit" data types
Previous Message christian.storm 2009-09-17 18:03:33 Re: noapic option