Craig Gibson <craiggib@gmail.com> writes:
> I get a daily CSV file of 6.5 million records. I create a temporary
> table and COPY them in. On completion I create an index on the mdnid
> column. This column is also indexed in table 2. This part is very
> fast. I had some 'checkpoint too often' issues, but that I have
> resolved.
FWIW, you probably should also issue an ANALYZE on the temp table after
you've loaded it. If you skip that, the planner is working blind as to
column statistics and is quite likely to choose inappropriate plans.
I concur with the other comment that you might be able to make this a
lot faster if you could convert it into a couple of multiple-row
commands instead of doing a manual loop. But you'd need up-to-date
statistics to get a decent plan for that, too ...
regards, tom lane