Re: Planner estimates cost of 'like' a lot lower than '='?? - Mailing list pgsql-general

From Tom Lane
Subject Re: Planner estimates cost of 'like' a lot lower than '='??
Date
Msg-id 8869.995842359@sss.pgh.pa.us
Whole thread Raw
In response to Re: Planner estimates cost of 'like' a lot lower than '='??  (Mats Lofkvist <mal@algonet.se>)
List 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

pgsql-general by date:

Previous
From: Mats Lofkvist
Date:
Subject: Re: Planner estimates cost of 'like' a lot lower than '='??
Next
From: missive@frontiernet.net (Lee Harr)
Date:
Subject: Re: Copy and serial type problem