How to implement table caching - Mailing list pgsql-general

From Andrus Moor
Subject How to implement table caching
Date
Msg-id ddo22k$gn7$1@news.hub.org
Whole thread Raw
Responses Re: How to implement table caching  ("Thomas F. O'Connell" <tfo@sitening.com>)
List pgsql-general
To increase performance, I'm thinking about storing copies of less
frequently changed tables in a client computer.
At startup client application compares last change times and downloads newer
tables from server.

CREATE TABLE lastchange (
  tablename CHAR(8) PRIMARY KEY,
  lastchange timestamp without time zone );

INSERT INTO lastupdated (tablename) values ('mytable1');
....
INSERT INTO lastupdated (tablename) values ('mytablen');

CREATE OR REPLACE FUNCTION setlastchange() RETURNS "trigger"
AS $$BEGIN
UPDATE lastchange SET lastchange='now' WHERE tablename=TG_RELNAME;
RETURN NULL;
END$$  LANGUAGE plpgsql STRICT;

CREATE TRIGGER mytable1_trig BEFORE INSERT OR UPDATE OR DELETE ON mytable1
   EXECUTE PROCEDURE setlastchange();
....
CREATE TRIGGER mytablen_trig BEFORE INSERT OR UPDATE OR DELETE ON mytablen
   EXECUTE PROCEDURE setlastchange();

Is table caching good idea?
Is this best way to implement table caching ?

Andrus.




pgsql-general by date:

Previous
From: Richard Huxton
Date:
Subject: Re:
Next
From: Oluwatope Akinniyi
Date:
Subject: SSL Certificate Strictness