X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 706AFD1B52C for ; Thu, 4 Sep 2003 23:11:16 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 58310-05 for ; Thu, 4 Sep 2003 20:10:48 -0300 (ADT) Received: from mail.4dmatrix.com (unknown [208.248.151.248]) by svr1.postgresql.org (Postfix) with ESMTP id D66F3D1B8A8 for ; Thu, 4 Sep 2003 20:10:43 -0300 (ADT) Received: from 4dmatrix.com (fw.4dmatrix.com [208.248.151.220]) by mail.4dmatrix.com (8.9.3/8.9.3) with ESMTP id QAA10220 for ; Thu, 4 Sep 2003 16:01:36 -0700 Message-ID: <3F57C59C.9060600@4dmatrix.com> Date: Thu, 04 Sep 2003 16:07:08 -0700 From: Josh Goldberg User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, ja, en MIME-Version: 1.0 To: pgsql-admin@postgresql.org Subject: experimenting with coalesce, strange EXPLAIN results X-Enigmail-Version: 0.76.5.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/83 X-Sequence-Number: 10171 I was experimenting with moving some of my case logic out of the application and into sql and found a strange EXPLAIN result with one of my COALESCE statements. Why is each subselect listed twice? This is in 7.3.4 on freebsd 4.8. cms3=# explain analyze select coalesce ((sELECT thumb FROM content_group_descriptor WHERE content_group_id = 140 AND language_id = 1),(SELECT tc.file FROM thumbnail_content tc, ccl WHERE tc.parent_content_id = cid AND ccgid = 140 limit 1)); QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------------------------- Result (cost=0.00..0.01 rows=1 width=0) (actual time=0.98..0.98 rows=1 loops=1) InitPlan -> Seq Scan on content_group_descriptor (cost=0.00..2.78 rows=1 width=4) (actual time=0.10..0.10 rows=0 loops=1) Filter: ((content_group_id = 140) AND (language_id = 1)) -> Seq Scan on content_group_descriptor (cost=0.00..2.78 rows=1 width=4) (never executed) Filter: ((content_group_id = 140) AND (language_id = 1)) -> Limit (cost=0.00..8.43 rows=1 width=12) (actual time=0.35..0.42 rows=1 loops=1) -> Nested Loop (cost=0.00..14.94 rows=2 width=12) (actual time=0.34..0.40 rows=2 loops=1) -> Seq Scan on content_collection (cost=0.00..5.46 rows=1 width=4) (actual time=0.24..0.26 rows=3 loops=1) Filter: (content_collection_group_id = 140) -> Index Scan using parent_file_key on thumbnail_content tc (cost=0.00..6.83 rows=1 width=8) (actual time=0.02..0.02 rows=1 loops=3) Index Cond: (tc.parent_content_id = "outer".content_id) -> Limit (cost=0.00..8.43 rows=1 width=12) (actual time=0.32..0.39 rows=1 loops=1) -> Nested Loop (cost=0.00..14.94 rows=2 width=12) (actual time=0.31..0.37 rows=2 loops=1) -> Seq Scan on content_collection (cost=0.00..5.46 rows=1 width=4) (actual time=0.24..0.26 rows=3 loops=1) Filter: (content_collection_group_id = 140) -> Index Scan using parent_file_key on thumbnail_content tc (cost=0.00..6.83 rows=1 width=8) (actual time=0.01..0.02 rows=1 loops=3) Index Cond: (tc.parent_content_id = "outer".content_id) Total runtime: 1.14 msec (19 rows)