Execution Plans and Casts - Mailing list pgsql-sql

From Hans-Jürgen Schönig
Subject Execution Plans and Casts
Date
Msg-id 3E0AFADA.90205@cybertec.at
Whole thread Raw
List pgsql-sql
Does anybody know how the planner treats casts?
It seems as if casts are not taken into consideration when planning the 
query because the costs  seem to stay the same.


[hs@backup mag]$ psql -p 5400 test -c "EXPLAIN SELECT id FROM t_data1"                           QUERY PLAN
-------------------------------------------------------------------Seq Scan on t_data1  (cost=0.00..168966.00
rows=10000000width=4)
 
(1 row)

[hs@backup mag]$ psql -p 5400 test -c "EXPLAIN SELECT id::numeric FROM 
t_data1"                           QUERY PLAN
-------------------------------------------------------------------Seq Scan on t_data1  (cost=0.00..168966.00
rows=10000000width=4)
 
(1 row)

[hs@backup mag]$ psql -p 5400 test -c "EXPLAIN SELECT id::text FROM t_data1"                           QUERY PLAN
-------------------------------------------------------------------Seq Scan on t_data1  (cost=0.00..168966.00
rows=10000000width=4)
 
(1 row)

[hs@backup mag]$ psql -p 5400 test -c "EXPLAIN SELECT COUNT(id::text) 
FROM t_data1"                              QUERY PLAN
-------------------------------------------------------------------------Aggregate  (cost=193966.00..193966.00 rows=1
width=4) ->  Seq Scan on t_data1  (cost=0.00..168966.00 rows=10000000 width=4)
 
(2 rows)

[hs@backup mag]$ psql -p 5400 test -c "EXPLAIN SELECT COUNT(id) FROM 
t_data1"                              QUERY PLAN
-------------------------------------------------------------------------Aggregate  (cost=193966.00..193966.00 rows=1
width=4) ->  Seq Scan on t_data1  (cost=0.00..168966.00 rows=10000000 width=4)
 
(2 rows)

   Hans


<http://kernel.cybertec.at>



pgsql-sql by date:

Previous
From: Hans-Jürgen Schönig
Date:
Subject: CREATE INDEX question
Next
From: Evgen Potemkin
Date:
Subject: Reference integrity question