Skip to content
Snippets Groups Projects
  1. Apr 30, 2012
    • Tom Lane's avatar
      Converge all SQL-level statistics timing values to float8 milliseconds. · 809e7e21
      Tom Lane authored
      This patch adjusts the core statistics views to match the decision already
      taken for pg_stat_statements, that values representing elapsed time should
      be represented as float8 and measured in milliseconds.  By using float8,
      we are no longer tied to a specific maximum precision of timing data.
      (Internally, it's still microseconds, but we could now change that without
      needing changes at the SQL level.)
      
      The columns affected are
      pg_stat_bgwriter.checkpoint_write_time
      pg_stat_bgwriter.checkpoint_sync_time
      pg_stat_database.blk_read_time
      pg_stat_database.blk_write_time
      pg_stat_user_functions.total_time
      pg_stat_user_functions.self_time
      pg_stat_xact_user_functions.total_time
      pg_stat_xact_user_functions.self_time
      
      The first four of these are new in 9.2, so there is no compatibility issue
      from changing them.  The others require a release note comment that they
      are now double precision (and can show a fractional part) rather than
      bigint as before; also their underlying statistics functions now match
      the column definitions, instead of returning bigint microseconds.
      809e7e21
    • Tom Lane's avatar
      Rename I/O timing statistics columns to blk_read_time and blk_write_time. · 1dd89ead
      Tom Lane authored
      This seems more consistent with the pre-existing choices for names of
      other statistics columns.  Rename assorted internal identifiers to match.
      1dd89ead
  2. Apr 05, 2012
  3. Jan 26, 2012
  4. Jan 19, 2012
    • Magnus Hagander's avatar
      Separate state from query string in pg_stat_activity · 4f42b546
      Magnus Hagander authored
      This separates the state (running/idle/idleintransaction etc) into
      it's own field ("state"), and leaves the query field containing just
      query text.
      
      The query text will now mean "current query" when a query is running
      and "last query" in other states. Accordingly,the field has been
      renamed from current_query to query.
      
      Since backwards compatibility was broken anyway to make that, the procpid
      field has also been renamed to pid - along with the same field in
      pg_stat_replication for consistency.
      
      Scott Mead and Magnus Hagander, review work from Greg Smith
      4f42b546
  5. Jan 02, 2012
  6. Nov 09, 2011
    • Heikki Linnakangas's avatar
      In COPY, insert tuples to the heap in batches. · d326d9e8
      Heikki Linnakangas authored
      This greatly reduces the WAL volume, especially when the table is narrow.
      The overhead of locking the heap page is also reduced. Reduced WAL traffic
      also makes it scale a lot better, if you run multiple COPY processes at
      the same time.
      d326d9e8
  7. Oct 21, 2011
    • Tom Lane's avatar
      Code review for pgstat_get_crashed_backend_activity patch. · f9c92a5a
      Tom Lane authored
      Avoid possibly dumping core when pgstat_track_activity_query_size has a
      less-than-default value; avoid uselessly searching for the query string
      of a successfully-exited backend; don't bother putting out an ERRDETAIL if
      we don't have a query to show; some other minor stylistic improvements.
      f9c92a5a
    • Robert Haas's avatar
      Try to log current the query string when a backend crashes. · c8e8b5a6
      Robert Haas authored
      To avoid minimize risk inside the postmaster, we subject this feature
      to a number of significant limitations.  We very much wish to avoid
      doing any complex processing inside the postmaster, due to the
      posssibility that the crashed backend has completely corrupted shared
      memory.  To that end, no encoding conversion is done; instead, we just
      replace anything that doesn't look like an ASCII character with a
      question mark.  We limit the amount of data copied to 1024 characters,
      and carefully sanity check the source of that data.  While these
      restrictions would doubtless be unacceptable in a general-purpose
      logging facility, even this limited facility seems like an improvement
      over the status quo ante.
      
      Marti Raudsepp, reviewed by PDXPUG and myself
      c8e8b5a6
  8. Sep 09, 2011
    • Tom Lane's avatar
      Move Timestamp/Interval typedefs and basic macros into datatype/timestamp.h. · a7801b62
      Tom Lane authored
      As per my recent proposal, this refactors things so that these typedefs and
      macros are available in a header that can be included in frontend-ish code.
      I also changed various headers that were undesirably including
      utils/timestamp.h to include datatype/timestamp.h instead.  Unsurprisingly,
      this showed that half the system was getting utils/timestamp.h by way of
      xlog.h.
      
      No actual code changes here, just header refactoring.
      a7801b62
  9. May 30, 2011
    • Tom Lane's avatar
      Fix VACUUM so that it always updates pg_class.reltuples/relpages. · b4b6923e
      Tom Lane authored
      When we added the ability for vacuum to skip heap pages by consulting the
      visibility map, we made it just not update the reltuples/relpages
      statistics if it skipped any pages.  But this could leave us with extremely
      out-of-date stats for a table that contains any unchanging areas,
      especially for TOAST tables which never get processed by ANALYZE.  In
      particular this could result in autovacuum making poor decisions about when
      to process the table, as in recent report from Florian Helmberger.  And in
      general it's a bad idea to not update the stats at all.  Instead, use the
      previous values of reltuples/relpages as an estimate of the tuple density
      in unvisited pages.  This approach results in a "moving average" estimate
      of reltuples, which should converge to the correct value over multiple
      VACUUM and ANALYZE cycles even when individual measurements aren't very
      good.
      
      This new method for updating reltuples is used by both VACUUM and ANALYZE,
      with the result that we no longer need the grotty interconnections that
      caused ANALYZE to not update the stats depending on what had happened
      in the parent VACUUM command.
      
      Also, fix the logic for skipping all-visible pages during VACUUM so that it
      looks ahead rather than behind to decide what to do, as per a suggestion
      from Greg Stark.  This eliminates useless scanning of all-visible pages at
      the start of the relation or just after a not-all-visible page.  In
      particular, the first few pages of the relation will not be invariably
      included in the scanned pages, which seems to help in not overweighting
      them in the reltuples estimate.
      
      Back-patch to 8.4, where the visibility map was introduced.
      b4b6923e
  10. Apr 10, 2011
  11. Feb 17, 2011
  12. Feb 10, 2011
  13. Jan 03, 2011
  14. Jan 01, 2011
  15. Nov 15, 2010
    • Robert Haas's avatar
      Add new buffers_backend_fsync field to pg_stat_bgwriter. · 3134d886
      Robert Haas authored
      This new field counts the number of times that a backend which writes a
      buffer out to the OS must also fsync() it.  This happens when the
      bgwriter fsync request queue is full, and is generally detrimental to
      performance, so it's good to know when it's happening.  Along the way,
      log a new message at level DEBUG1 whenever we fail to hand off an fsync,
      so that the problem can also be seen in examination of log files
      (if the logging level is cranked up high enough).
      
      Greg Smith, with minor tweaks by me.
      3134d886
  16. Oct 12, 2010
    • Tom Lane's avatar
      Remove some unnecessary tests of pgstat_track_counts. · f4d242ef
      Tom Lane authored
      We may as well make pgstat_count_heap_scan() and related macros just count
      whenever rel->pgstat_info isn't null.  Testing pgstat_track_counts buys
      nothing at all in the normal case where that flag is ON; and when it's OFF,
      the pgstat_info link will be null, so it's still a useless test.
      
      This change is unlikely to buy any noticeable performance improvement,
      but a cycle shaved is a cycle earned; and my investigations earlier today
      convinced me that we're down to the point where individual instructions in
      the inner execution loops are starting to matter.
      f4d242ef
  17. Sep 20, 2010
  18. Aug 21, 2010
  19. Aug 08, 2010
  20. Feb 26, 2010
  21. Jan 28, 2010
  22. Jan 19, 2010
  23. Jan 02, 2010
  24. Dec 30, 2009
    • Tom Lane's avatar
      Revise pgstat's tracking of tuple changes to improve the reliability of · 48c192c1
      Tom Lane authored
      decisions about when to auto-analyze.
      
      The previous code depended on n_live_tuples + n_dead_tuples - last_anl_tuples,
      where all three of these numbers could be bad estimates from ANALYZE itself.
      Even worse, in the presence of a steady flow of HOT updates and matching
      HOT-tuple reclamations, auto-analyze might never trigger at all, even if all
      three numbers are exactly right, because n_dead_tuples could hold steady.
      
      To fix, replace last_anl_tuples with an accurately tracked count of the total
      number of committed tuple inserts + updates + deletes since the last ANALYZE
      on the table.  This can still be compared to the same threshold as before, but
      it's much more trustworthy than the old computation.  Tracking this requires
      one more intra-transaction counter per modified table within backends, but no
      additional memory space in the stats collector.  There probably isn't any
      measurable speed difference; if anything it might be a bit faster than before,
      since I was able to eliminate some per-tuple arithmetic operations in favor of
      adding sums once per (sub)transaction.
      
      Also, simplify the logic around pgstat vacuum and analyze reporting messages
      by not trying to fold VACUUM ANALYZE into a single pgstat message.
      
      The original thought behind this patch was to allow scheduling of analyzes
      on parent tables by artificially inflating their changes_since_analyze count.
      I've left that for a separate patch since this change seems to stand on its
      own merit.
      48c192c1
  25. Nov 29, 2009
  26. Jun 11, 2009
  27. Jan 04, 2009
  28. Jan 01, 2009
  29. Dec 17, 2008
    • Heikki Linnakangas's avatar
      Don't reset pg_class.reltuples and relpages in VACUUM, if any pages were · dcf84099
      Heikki Linnakangas authored
      skipped. We could update relpages anyway, but it seems better to only
      update it together with reltuples, because we use the reltuples/relpages
      ratio in the planner. Also don't update n_live_tuples in pgstat.
      
      ANALYZE in VACUUM ANALYZE now needs to update pg_class, if the
      VACUUM-phase didn't do so. Added some boolean-passing to let analyze_rel
      know if it should update pg_class or not.
      
      I also moved the relcache invalidation (to update rd_targblock) from
      vac_update_relstats to where RelationTruncate is called, because
      vac_update_relstats is not called for partial vacuums anymore. It's more
      obvious to send the invalidation close to the truncation that requires it.
      
      Per report by Ned T. Crigler.
      dcf84099
  30. Nov 03, 2008
    • Tom Lane's avatar
      Change the pgstat logic so that the stats collector writes the stats file only · 3c2313f4
      Tom Lane authored
      upon requests from backends, rather than on a fixed 500msec cycle.  (There's
      still throttling logic to ensure it writes no more often than once per
      500msec, though.)  This should result in a significant reduction in stats file
      write traffic in typical scenarios where the stats are demanded only
      infrequently.
      
      This approach also means that the former difficulty with changing
      stats_temp_directory on-the-fly has gone away, so remove the caution about
      that as well as the thrashing we did to minimize the trouble window.
      
      In passing, also fix pgstat_report_stat() so that we will send a stats
      message if we have function call stats but not table stats to report;
      this fixes a bug in the recent patch to support function-call stats.
      
      Martin Pihlak
      3c2313f4
  31. Aug 15, 2008
  32. Jun 30, 2008
    • Heikki Linnakangas's avatar
      Turn PGBE_ACTIVITY_SIZE into a GUC variable, track_activity_query_size. · 995fb742
      Heikki Linnakangas authored
      As the buffer could now be a lot larger than before, and copying it could
      thus be a lot more expensive than before, use strcpy instead of memcpy to
      copy the query string, as was already suggested in comments. Also, only copy
      the PgBackendStatus struct and string if the slot is in use.
      
      Patch by Thomas Lee, with some changes by me.
      995fb742
  33. Jun 19, 2008
  34. May 15, 2008
  35. Apr 03, 2008
    • Tom Lane's avatar
      Teach ANALYZE to distinguish dead and in-doubt tuples, which it formerly · 51e1445f
      Tom Lane authored
      classed all as "dead"; also get it to count DEAD item pointers as dead rows,
      instead of ignoring them as before.  Also improve matters so that tuples
      previously inserted or deleted by our own transaction are handled nicely:
      the stats collector's live-tuple and dead-tuple counts will end up correct
      after our transaction ends, regardless of whether we end in commit or abort.
      
      While there's more work that could be done to improve the counting of in-doubt
      tuples in both VACUUM and ANALYZE, this commit is enough to alleviate some
      known bad behaviors in 8.3; and the other stuff that's been discussed seems
      like research projects anyway.
      
      Pavan Deolasee and Tom Lane
      51e1445f
  36. Mar 24, 2008
    • Tom Lane's avatar
      Adjust the recent patch for reporting of deadlocked queries so that we report · 9b8e1eb3
      Tom Lane authored
      query texts only to the server log.  This eliminates the issue of possible
      leaking of security-sensitive data in other sessions' queries.  Since the
      log is presumed secure, we can now log the queries of all sessions involved
      in the deadlock, whether or not they belong to the same user as the one
      reporting the failure.
      9b8e1eb3
Loading