is there any way to update the stats inside a transaction? what i have is
something like:
select count(*) from foo;
-> 0
begin;
copy foo from '/tmp/foo'; -- about 100k rows
-- run some queries on foo which perform horribly because the stats
-- are way off (100k rows v. 0 rows)
commit;
it seems that you cannot run analyze inside a transaction:
begin;
analyze foo;
ERROR: ANALYZE cannot run inside a BEGIN/END block
i am using version 7.2.3.
any work-a-rounds? should i try updating pg_statistic manually?
On Fri, 31 Oct 2003, Josh Berkus wrote:
> Among other things, ANALYZE tells postgres how many rows are in the table. So
> if you add a PK constraint after loading 10 million rows without ANALYZE,
> PostgreSQL is likely to think that there is only one row in the table ... and
> choose a nested loop or some other really inefficient method of checking for
> uniqueness.