ctid matching behavior changed?

Started by Greg Sabino Mullaneover 22 years ago2 messageshackers
Jump to latest
#1Greg Sabino Mullane
greg@turnstep.com

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
NotDashEscaped: You need GnuPG to verify this message

Why is the subselect never executed for the inner select?

pgrocks=> SELECT VERSION() UNION ALL SELECT oid::text FROM pg_class WHERE ctid = (SELECT ctid FROM pg_class LIMIT 1);
version
--------------------------------------------------------------
PostgreSQL 7.3.4 on i686-pc-linux-gnu, compiled by GCC 3.0.1
16416
(2 rows)

pgrocks=> SELECT VERSION() UNION ALL SELECT oid::text FROM pg_class WHERE ctid = (SELECT ctid FROM pg_class LIMIT 1);
version
-----------------------------------------------------------------
PostgreSQL 7.4beta3 on i686-pc-linux-gnu, compiled by GCC 3.0.1
(1 row)

7.3.4:
pgrocks=> EXPLAIN ANALYZE SELECT oid FROM pg_class WHERR ctid = (SELECT ctid FROM pg_class LIMIT 1);
QUERY PLAN
------------------------------------------------------------------------------------------------------
Tid Scan on pg_class (cost=0.00..4.01 rows=1 width=4) (actual time=0.01..0.01 rows=1 loops=1)
Filter: (ctid = $0)
InitPlan
-> Limit (cost=0.00..0.03 rows=1 width=6) (actual time=0.02..0.03 rows=1 loops=1)
-> Seq Scan on pg_class (cost=0.00..21.82 rows=682 width=6) (actual time=0.02..0.02 rows=2 loops=1)

7.4beta3:
pgrocks=> EXPLAIN ANALYZE SELECT oid FROM pg_class WHERR ctid = (SELECT ctid FROM pg_class LIMIT 1);
QUERY PLAN
------------------------------------------------------------------------------------------------
Tid Scan on pg_class (cost=0.04..4.05 rows=2 width=4) (actual time=0.00..0.00 rows=0 loops=1)
Filter: (ctid = $0)
InitPlan
-> Limit (cost=0.00..0.04 rows=1 width=6) (never executed)
-> Seq Scan on pg_class (cost=0.00..9.30 rows=230 width=6) (never executed)

--
Greg Sabino Mullane greg@turnstep.com
PGP Key: 0x14964AC8 200309251929
-----BEGIN PGP SIGNATURE-----
Comment: http://www.turnstep.com/pgp.html

iD8DBQE/c3r2vJuQZxSWSsgRAjorAJ9SyKGsLWk0zQkn1a6f63itq/p1xACg06IF
J28TltScrDcHvUec97RsTTM=
=3W1F
-----END PGP SIGNATURE-----

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Greg Sabino Mullane (#1)
Re: ctid matching behavior changed?

"Greg Sabino Mullane" <greg@turnstep.com> writes:

Why is the subselect never executed for the inner select?

Fixed. I'm kinda surprised that code ever worked; it was trying to run
a sub-plan before the rest of the executor was set up.

regards, tom lane