Re: Random Page Cost and Planner

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, Bryan.

I was just about to reply to the thread, thanks for asking. Clustering was key. After rebooting the machine (just to make sure absolutely nothing was cached), I immediately ran a report on Toronto: 5.25 seconds!

Here's what I did:
  1. Created a new set of tables that matched the old set, with statistics of 1000 on the station and taken (date) columns.
  2. Inserted the data from the old hierarchy into the new set, ordered by station id then by date (same seven child tables as before: one per category).
  3. Added three indexes per table: (a) station id; (b) date taken; and (c) station-taken-category.
  4. Set the station-taken-category index as CLUSTER.
  5. Vacuumed the new tables.
  6. Dropped the old tables.
  7. Set the following configuration values:
I ran a few more reports (no reboots, but reading vastly different data sets):
No full table scans. I imagine some indexes are not strictly necessary and will test to see which can be removed (my guess: the station and taken indexes). The problem was that the station ids were scattered and so PostgreSQL presumed a full table scan would be faster.

Physically ordering the data by station ids triggers index use every time.

Next week's hardware upgrade should halve those times -- unless anyone has further suggestions to squeeze more performance out of PG. ;-)

Dave


[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux