Database Reference
In-Depth Information
rule
Rules are instructions to substitute one action for another. PostgreSQL uses rules
internally to define views. As an example, you could create a view as follows:
CREATE VIEW vw_pupils AS SELECT * FROM pupils WHERE active ;
Behind the scenes, PostgresSQL adds an INSTEAD OF SELECT rule dictating that
when you try to select from a table called vw_pupils , you will get back only rows
from the pupils table in which the active field is true .
A rule is also useful in lieu of certain simple triggers. Normally a trigger is called
for each record in your update/insert/delete statement. A rule, instead, rewrites the
action (your SQL statement) or inserts additional SQL statements on top of your
original. This avoids the overhead of touching each record separately. For changing
data, triggers are the preferred method of operation. Many PostgreSQL users con‐
sider rules to be legacy technology for action-based queries because they are much
harder to debug when things go wrong, and you can write rules only in SQL, not
in any of the other PLs.
What's New in Latest Versions of PostgreSQL?
The PostgreSQL release cycle is fairly predictable, with major releases slated for each
September. Each new version adds enhancements to ease of use, stability, security, per‐
formance, and avant-garde features. The upgrade process gets simpler with each new
version. The lesson here? Upgrade, and upgrade often. For a summary chart of key
features added in each release, check the PostgreSQL Feature Matrix .
Why Upgrade?
If you're using PostgreSQL 8.4 or below, upgrade now! Version 8.4 entered end-of-life
(EOL) support in July 2014. Details about PostgreSQL EOL policy can be found at the
PostgreSQL Release Support Policy . EOL is not a place you want to be. New security
updates and fixes to serious bugs will no longer be available. You'll need to hire speci‐
alized PostgreSQL core consultants to patch problems or to implement workarounds
—probably not a cheap proposition, assuming you can even locate someone willing to
do the work.
Regardless of which major version you are running, you should always try to keep up
with the latest micro versions. An upgrade from, say, 8.4.17 to 8.4.21, requires just binary
file replacement and a restart. Micro versions only patch bugs. Nothing will stop work‐
ing after a micro upgrade, and performing a micro upgrade can in fact save you grief.
Search WWH ::




Custom Search