Christopher Browne cbbrowne at ca.afilias.info
Fri Dec 14 08:42:38 PST 2007
Simon Riggs <simon at 2ndquadrant.com> writes:
> in copy_set() line 3073 of /src/slon/remote_worker.c
>
> uses DELETE rather than TRUNCATE prior to COPY
>
>
> So some optimizations here could be
> - use TRUNCATE to speed up refreshing a copy operation
> - this will then allow (from 8.3 onwards) fast COPY mode
>
> It's possible you've decided we don't need that part to be optimized,
> which is OK, I'm just pointing out what's possible.

The code I *think* you're talking about is the following, right?

----------- remote_worker.c v 1.162 ------------------------------
		if (archive_dir)
		{
			slon_mkquery(&query1,
			 "delete from only %s;\ncopy %s %s from stdin;", tab_fqname, tab_fqname,
						 nodeon73 ? "" : PQgetvalue(res3, 0, 0));
			rc = archive_append_ds(node, &query1);
... more code elided ...

??

If it is, then I'll suggest that this doesn't represent a very
interesting optimization, from three perspectives:

  1.  This query is only applied against a log shipping subscription
      (because of the enclosure in the "if (archive_dir)" clause).

      Different logic is applied against a normal subscriber node.

  2.  The normal logic for a subscriber is implemented in the function
      prepareTableForCopy() in src/base/slony1_funcs.sql, and it
      *does* try doing a TRUNCATE, falling back to DELETE if it
      encounters an exception (which tends to imply that there are
      foreign keys getting in the way of TRUNCATE).

  3.  On a log shipping node, we may fairly reasonably expect the
      table to be empty, because you normally initialize with a
      schema but no data, thereby making the DELETE a formality
      (to make sure the table truly is empty).

      If there's no data in the table, DELETE should be pretty cheap
      ;-).

I don't see this being a terribly fruitful destination for further
optimization.  There would be some possibly non-zero value in drawing
in the same logic as in prepareTableForCopy(), but I'm not sure it's
worth complicating the code that way :-(.
-- 
let name="cbbrowne" and tld="linuxdatabases.info" in String.concat "@" [name;tld];;
http://linuxdatabases.info/info/linuxxian.html
We  are MICROS~1.   You will  be assimilated.   Resistance  is futile.
(Attributed to B.G., Gill Bates)


More information about the Slony1-general mailing list