pg_stat_statements_optimization_2012_04_08.patch

application/octet-stream

Filename: pg_stat_statements_optimization_2012_04_08.patch
Type: application/octet-stream
Part: 0
Message: Re: Re: pg_stat_statements normalisation without invasive changes to the parser (was: Next steps on pg_stat_statements normalisation)

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: context
File+
contrib/pg_stat_statements/pg_stat_statements.c 6 2
diff contrib/pg_stat_statements/pg_stat_statements.c
index 8f5c9b0..d8b829d
*** a/contrib/pg_stat_statements/pg_stat_statements.c
--- b/contrib/pg_stat_statements/pg_stat_statements.c
*************** pgss_store(const char *query, uint32 que
*** 964,975 ****
  		 * strings are normalized on a best effort basis, though it would be
  		 * difficult to demonstrate this even under artificial conditions.)
  		 * But if we found the entry already present, don't let this call
! 		 * increment its usage.
  		 */
  		if (!entry)
  			usage = pgss->cur_median_usage;
  		else
! 			usage = 0;
  	}
  	else
  	{
--- 964,978 ----
  		 * strings are normalized on a best effort basis, though it would be
  		 * difficult to demonstrate this even under artificial conditions.)
  		 * But if we found the entry already present, don't let this call
! 		 * increment its usage - just fastpath out of here without even
! 		 * acquiring a spinlock for the entry, since the only reason we'll need
! 		 * to do so in a call from pgss_post_parse_analyze() is to initially set
! 		 * usage to the median to make the entry sticky.
  		 */
  		if (!entry)
  			usage = pgss->cur_median_usage;
  		else
! 			goto done;
  	}
  	else
  	{
*************** pgss_store(const char *query, uint32 que
*** 1060,1065 ****
--- 1063,1069 ----
  		SpinLockRelease(&e->mutex);
  	}

+ done:
  	LWLockRelease(pgss->lock);

  	/* We postpone this pfree until we're out of the lock */