Обсуждение: Execution Plans and Casts

Поиск
Список
Период
Сортировка

Execution Plans and Casts

От
Hans-Jürgen Schönig
Дата:
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>