set join_collapse_limit to 5;
set from_collapse_limit to 5;

drop table if exists tt1 cascade;create temporary table tt1 (fldtmp1 timestamp, fldtmp2 bytea) without oids
;
INSERT INTO pg_temp.tt1 (fldtmp1, fldtmp2) SELECT
T1.fld1,
T1.fld2
FROM table1 T1
	LIMIT 1000
;
ANALYZE pg_temp.tt1
;
drop table if exists tt2 cascade;create temporary table tt2 (fldtmp1 timestamp, fldtmp2 bytea) without oids
;
INSERT INTO pg_temp.tt2 (fldtmp1, fldtmp2) SELECT
T1.fld1,
T1.fld2

FROM table1 T1
	LIMIT 1000
;
ANALYZE pg_temp.tt2
;
drop table if exists tt3 cascade;create temporary table tt3 (fldtmp1 timestamp, fldtmp2 bytea) without oids
;
INSERT INTO pg_temp.tt3 (fldtmp1, fldtmp2) SELECT
T1.fld1,
T1.fld2

FROM table1 T1
 LIMIT 1000
;
ANALYZE pg_temp.tt3
;
drop table if exists tt4 cascade;create temporary table tt4 (fldtmp1 timestamp, fldtmp2 bytea) without oids
;
INSERT INTO pg_temp.tt4 (fldtmp1, fldtmp2) SELECT
T1.fld1,
T1.fld2

FROM table1 T1
LIMIT 1000
;
ANALYZE pg_temp.tt4
;
drop table if exists tt5 cascade;create temporary table tt5 (fldtmp1 timestamp, fldtmp2 bytea) without oids
;
INSERT INTO pg_temp.tt5 (fldtmp1, fldtmp2) SELECT
T1.fld1,
T1.fld2

FROM table1 T1
LIMIT 1000
;
ANALYZE pg_temp.tt5
;
drop table if exists tt6 cascade;create temporary table tt6 (fldtmp1 timestamp, fldtmp2 bytea) without oids
;
INSERT INTO pg_temp.tt6 (fldtmp1, fldtmp2) SELECT
T1.fld1,
T1.fld2

FROM table1 T1
LIMIT 1000
;
ANALYZE pg_temp.tt6
;
explain analyze SELECT
T1.fld2,
T2.fldtmp1,
T3.fldtmp1,
T4.fldtmp1,
T5.fldtmp1,
T6.fldtmp1,
T7.fldtmp1
FROM table1 T1
LEFT OUTER JOIN pg_temp.tt1 T2
ON ( T2.fldtmp2 = T1.fld2)
LEFT OUTER JOIN pg_temp.tt2 T3
ON (T3.fldtmp2 = T1.fld2)
LEFT OUTER JOIN pg_temp.tt3 T4
ON ( T4.fldtmp2 = T1.fld2)
LEFT OUTER JOIN pg_temp.tt5 T5
ON (T5.fldtmp2 = T1.fld2)
LEFT OUTER JOIN pg_temp.tt6 T6
ON (T6.fldtmp2 = T1.fld2)
LEFT OUTER JOIN pg_temp.tt4 T7
ON ( T7.fldtmp2 = T1.fld2)
WHERE  (( T1.fld2 IN ( VALUES('\\230\\211\\030f\\332\\261R\\333\\021\\356\\337z5\\336\\032\\372'::bytea), ('\\235\\204 \\004\\017\\353\\301\\200\\021\\355a&d}\\245\\312'::bytea))));

