pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Hans-Jürgen Schönig <hs@cybertec.at>
To: pgsql-sql@postgresql.org
Subject: Execution Plans and Casts
Date: Thu, 26 Dec 2002 13:49:30 +0100
Message-ID: <3E0AFADA.90205@cybertec.at> (raw)

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=10000000 width=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=10000000 width=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=10000000 width=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;




Message-ID: <3E0AFADA.90205@cybertec.at>
Permalink:  ../3E0AFADA.90205@cybertec.at/
Also on:    postgresql.org/message-id/3E0AFADA.90205@cybertec.at

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: hs@cybertec.at
  Subject: Re: Execution Plans and Casts
  In-Reply-To: <3E0AFADA.90205@cybertec.at>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox