Re: Planner estimates cost of 'like' a lot lower than '='??

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Mats Lofkvist <mal@algonet.se>
Cc: pgsql-general@postgreSQL.org
Date: 2001-07-22T22:52:39Z
Lists: pgsql-general
Mats Lofkvist <mal@algonet.se> writes:
> I just did a quick test before going to bed but 7.2devel seems
> do to what we want:

> testdb=> select count(*) from data where value like 'test_0';
>  count 
> -------
>      9
> (1 row)

> testdb=> explain select count(*) from data where value like 'test_0';
> NOTICE:  QUERY PLAN:

> Aggregate  (cost=5581.45..5581.45 rows=1 width=0)
>   ->  Seq Scan on data  (cost=0.00..5580.69 rows=306 width=0)

> EXPLAIN
> testdb=> select count(*) from data where value >= 'test' and value < 'tesu';
>  count 
> -------
>  10000
> (1 row)

> testdb=> explain select count(*) from data where value >= 'test' and value < 'tesu';
> NOTICE:  QUERY PLAN:

> Aggregate  (cost=6007.24..6007.24 rows=1 width=0)
>   ->  Seq Scan on data  (cost=0.00..5986.02 rows=8487 width=0)

> EXPLAIN

Those estimates do look a lot closer to reality, all right.  And the
join plan is the right thing now.  Excellent...

			regards, tom lane