I have a table with 45 million rows, partitioned on a date field. Each of
the partitions has a primary key. There are 3 partitions so far, 15
million records each.
I retrieve up to 200k document id's (primary key for each partition) from
the application and put them into a temporary table which I then join to
the partitioned monster and some other tables. I discovered a strange
thing: the optimizer chooses hash join, with a full table scan of all
underlying tables unless I create a primary key on the temporary table,
in which case the appropriate nested loops join is chosen.
What makes optimizer do that and why? I can get by the problem by
disabling hash join in the postgresql.conf but I don't like that
solution. Not even lowering random page cost to the same cost as
sequential page cost helps.
My question is how does the optimizer calculate stats for the temporary
tables? I am probably not expected to do a vacuum analyze on the
temporary table, after finishing the inserts? How exactly does the
with the temporary tables?
Postgresql is 8.4.4 on 64 bit Red Hat 5.5
Sr. Oracle DBA
New York, NY 10036
pgsql-novice by date
|Next:||From: Josh Kupershmidt||Date: 2010-09-23 14:26:28|
|Subject: Re: Statistics with temporary tables, optimizer question|
|Previous:||From: Rob Richardson||Date: 2010-09-23 12:49:08|
|Subject: Re: Table transfer|