Closed gmittal closed 1 year ago
Hi. Are you pointing out that the join between the chn(char_name) table and the other tables is not a Hash Join as a problem ? If so, please try following workarounds.
If you use PostgreSQL v13, please use a latest pg_hint_plan (HEAD). Latest commit (https://github.com/ossc-db/pg_hint_plan/commit/e891d547ad3f37f4ad971a28834a752564765d18) may fix your problem.
If you use PostgreSQL v12 or earlier, try setting the work_mem parameter to a larger value than it is now, or add SeqScan(chn) to the HINT clause.
Regards,
I encountered a similar problem:
job=# /*+ Leading(t mi mi_idx) */ explain select count(*) from title t, movie_info mi, movie_info_idx mi_idx where t.id=mi.movie_id and t.id=mi_idx.movie_id and mi.info_type_id > 16 and mi_idx.info_type_id = 100;
but get
Aggregate (cost=479389.64..479389.65 rows=1 width=8)
-> Hash Join (cost=118376.83..478371.27 rows=407350 width=0)
Hash Cond: (mi.movie_id = t.id)
-> Seq Scan on movie_info mi (cost=0.00..347529.39 rows=2237746 width=4)
Filter: (info_type_id > 16)
-> Hash (cost=112623.81..112623.81 rows=460242 width=8)
-> Hash Join (cost=30938.46..112623.81 rows=460242 width=8)
Hash Cond: (t.id = mi_idx.movie_id)
-> Seq Scan on title t (cost=0.00..61281.03 rows=2528303 width=4)
-> Hash (cost=25185.44..25185.44 rows=460242 width=4)
-> Seq Scan on movie_info_idx mi_idx (cost=0.00..25185.44 rows=460242 width=4)
Filter: (info_type_id = 100)
I'm using PG v12 and pg_hint_plan 1.3.7 and the work_mem is 16GB.
This does not seem to be relevant anymore, hence closing for now.
I have turned
geqo
off and increasedfrom_collapse_limit
andjoin_collapse_limit
to appropriate values. I am attempting to plan the following:However, pg_hint_plan claims that all hints are used but the returned QEP does not follow the join order specified above.
Resulting execution plan (which very clearly does not follow the join order specified by Leading):