Ticket #818 (closed defect: fixed)

Opened 2 years ago

Last modified 16 months ago

ANALYZE does not override statistics on empty table

Reported by: strk Owned by: pramsey
Priority: medium Milestone: PostGIS 2.0.0
Component: postgis Version: trunk
Keywords: Cc:

Description

Dunno if postgis can do anything here or is a postgresql thing. What happens is that there seems to be no way to clear statistics of a table after truncating it.

Try with st_estimated_extent: fill a table, analyze, get estimated extent, truncate, vacuum and analyze again, get estimated_extent again: you'll obtain the old estimate.

Change History

Changed 2 years ago by strk

Oh, this is against postgresql 8.4.3

Changed 2 years ago by strk

geometry_gist_selectivity.c and lwgeom_estimate.c both contain a static compute_geometry_stats function. What's the deal ?

Changed 2 years ago by mcayland

IIRC Paul found a performance regression between the old and new index code, and so currently both versions are built to allow for testing/comparison.

Changed 16 months ago by strk

As of r8869 there's a single implementation of compute_geometry_stats, which is good.

Changed 16 months ago by strk

I see from PostgreSQL source code that our custom stats gathered is not even invoked if there are no rows, so the best we could do is reset the stats at the time of the typanalyze call.

Changed 16 months ago by strk

  • status changed from new to closed
  • resolution set to fixed

r8870 doesn't override statistics but changes st_estimated_extent to deal with the empty table case by looking at the core statistics (row count).

Such change fixes the TRUNCATE effect. I don't think we care about having correct statisticts on empty tables for other uses as any plan the planner makes it will still be very fast for an empty table...

Note: See TracTickets for help on using tickets.