Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9E8F14758FE for ; Thu, 26 Dec 2002 07:49:12 -0500 (EST) Received: from news.hub.org (news.hub.org [64.49.215.80]) by postgresql.org (Postfix) with ESMTP id 265954758E1 for ; Thu, 26 Dec 2002 07:49:12 -0500 (EST) Received: by news.hub.org (Postfix, from userid 8) id 097D143A8DE; Thu, 26 Dec 2002 07:49:12 -0500 (EST) From: =?ISO-8859-1?Q?Hans-J=FCrgen_Sch=F6nig?= X-Newsgroups: comp.databases.postgresql.sql Subject: Execution Plans and Casts Date: Thu, 26 Dec 2002 13:49:30 +0100 Organization: Hub.Org Networking Services (http://www.hub.org) Lines: 46 Message-ID: <3E0AFADA.90205@cybertec.at> Reply-To: hs@cybertec.at Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@news.hub.org User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20020826 X-Accept-Language: en-us, en To: pgsql-sql@postgresql.org X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/3 X-Sequence-Number: 10868 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