Download - Pdxpugday2010 pg90
![Page 3: Pdxpugday2010 pg90](https://reader034.vdocument.in/reader034/viewer/2022050801/554a5dd7b4c9054b328b5132/html5/thumbnails/3.jpg)
Introductions
__ __
/ \~~~/ \ . o O ( PostgreSQL? )
,----( oo )
/ \__ __/
/| (\ |(
^ \ /___\ /\ |
|__| |__|-"
![Page 4: Pdxpugday2010 pg90](https://reader034.vdocument.in/reader034/viewer/2022050801/554a5dd7b4c9054b328b5132/html5/thumbnails/4.jpg)
PostgreSQL
- Current version 8.4.4
- 9.0 is in Beta
- Release in August?
- Get it here:http://www.postgresql.org/ftp/source/9.0beta3/http://www.postgresql.org/developer/beta
![Page 5: Pdxpugday2010 pg90](https://reader034.vdocument.in/reader034/viewer/2022050801/554a5dd7b4c9054b328b5132/html5/thumbnails/5.jpg)
Contents
Full list of features:http://developer.postgresql.org/pgdocs/postgres/release-9-0.html
![Page 6: Pdxpugday2010 pg90](https://reader034.vdocument.in/reader034/viewer/2022050801/554a5dd7b4c9054b328b5132/html5/thumbnails/6.jpg)
To boldly go...
___________________ _-_
\__(==========/_=_/ ____.---’---‘---.____
\_ \ \----._________.----/
\ \ / / ‘-_-’
__,--‘.‘-’..’-_
/____ ||
‘--.____,-’
Based on overwhelming user demand, this release of PostgreSQLadds features that have been requested for years, like easy-to-use
replication, a mass permission facility, and anonymous code blocks.
![Page 7: Pdxpugday2010 pg90](https://reader034.vdocument.in/reader034/viewer/2022050801/554a5dd7b4c9054b328b5132/html5/thumbnails/7.jpg)
Seriously. It’s a big release
- New feature patches: 204
- Submitters: 84
- 2189 files changed, 214227 insertions(+), 125369 deletions(-)
![Page 8: Pdxpugday2010 pg90](https://reader034.vdocument.in/reader034/viewer/2022050801/554a5dd7b4c9054b328b5132/html5/thumbnails/8.jpg)
Add the ability to make mass permission changes per
schema using the new GRANT/REVOKE IN SCHEMAclause (Petr Jelinek)
postgres# GRANT SELECT,INSERT,UPDATE ON
ALL TABLES IN SCHEMA conference TO selena;
![Page 9: Pdxpugday2010 pg90](https://reader034.vdocument.in/reader034/viewer/2022050801/554a5dd7b4c9054b328b5132/html5/thumbnails/9.jpg)
Add ALTER DEFAULT PRIVILEGES command to control
privileges of newly-created objects (Petr Jelinek)
postgres# ALTER DEFAULT PRIVILEGES
IN SCHEMA conference
GRANT INSERT ON TABLES TO selena;
Use psql’s \ddp command to get info about
existing assignments of default privileges.
![Page 10: Pdxpugday2010 pg90](https://reader034.vdocument.in/reader034/viewer/2022050801/554a5dd7b4c9054b328b5132/html5/thumbnails/10.jpg)
Install server-side language PL/pgSQL by default (Bruce
Momjian)
Yes.
Also recall: CREATE [ OR REPLACE ] [ PROCEDURAL ]LANGUAGE name
![Page 11: Pdxpugday2010 pg90](https://reader034.vdocument.in/reader034/viewer/2022050801/554a5dd7b4c9054b328b5132/html5/thumbnails/11.jpg)
Implement anonymous functions using the DO statement,
a.k.a anonymous blocks (Petr Jelinek, Joshua Tolley,Hannu Valtonen)
DO $$
BEGIN
FOR x IN 1..10 LOOP
RAISE NOTICE ’Now at %’, x;
END LOOP;
END;$$;
![Page 12: Pdxpugday2010 pg90](https://reader034.vdocument.in/reader034/viewer/2022050801/554a5dd7b4c9054b328b5132/html5/thumbnails/12.jpg)
More DO...
DO $$
for i in range(10):
plpy.notice(i)
$$ language ’plpythonu’;
![Page 13: Pdxpugday2010 pg90](https://reader034.vdocument.in/reader034/viewer/2022050801/554a5dd7b4c9054b328b5132/html5/thumbnails/13.jpg)
MOAR DO...
DO $$
HAI
I HAS A VAR ITZ 0
IM IN YR LOOP
VAR R SUM OF VAR AN 1
VISIBLE VAR
BOTH SAEM VAR AN 10, O RLY?
YA RLY, GTFO
OIC
IM OUTTA YR LOOP
KTHXBYE
$$ language ’pllolcode’;
![Page 14: Pdxpugday2010 pg90](https://reader034.vdocument.in/reader034/viewer/2022050801/554a5dd7b4c9054b328b5132/html5/thumbnails/14.jpg)
Allow function calls to supply parameter names and match
them to named parameters in the function definition(Pavel Stehule)
(Demo.)
![Page 15: Pdxpugday2010 pg90](https://reader034.vdocument.in/reader034/viewer/2022050801/554a5dd7b4c9054b328b5132/html5/thumbnails/15.jpg)
Add support for to char() scientific notation output
(’EEEE’) (Pavel Stehule, Brendan Jurd)
postgres=# create table exponents_demo
(example numeric);
CREATE TABLE
postgres=# INSERT INTO exponents_demo
VALUES
(’10000000’),
(’2.54’),
(’3.1415’),
(’666’),
(’6.02e+23’),
(’5.29e-11’),
(’8675309’)
;
![Page 16: Pdxpugday2010 pg90](https://reader034.vdocument.in/reader034/viewer/2022050801/554a5dd7b4c9054b328b5132/html5/thumbnails/16.jpg)
Con’t
postgres=# SELECT * from exponents_demo ;
example
--------------------------
10000000
2.54
3.1415
666
602000000000000000000000
0.0000000000529
8675309
(7 rows)
![Page 17: Pdxpugday2010 pg90](https://reader034.vdocument.in/reader034/viewer/2022050801/554a5dd7b4c9054b328b5132/html5/thumbnails/17.jpg)
Con’t
postgres=# SELECT to_char(example, ’9.9EEEE’)
AS lookyhere
FROM exponents_demo ;
lookyhere
-----------
1.0e+07
2.5e+00
3.1e+00
6.7e+02
6.0e+23
5.3e-11
8.7e+06
(7 rows)
![Page 18: Pdxpugday2010 pg90](https://reader034.vdocument.in/reader034/viewer/2022050801/554a5dd7b4c9054b328b5132/html5/thumbnails/18.jpg)
RADIUS Authentication (Magnus Hagander)
#host database user CIDR-address auth-method [auth-options]
host all all 0.0.0.0/0 radius \
radiusserver=1.2.3.4 radiussecret=canttouchthis \
radiusport=1234 radiusidentifier=gabscooldatabase
![Page 19: Pdxpugday2010 pg90](https://reader034.vdocument.in/reader034/viewer/2022050801/554a5dd7b4c9054b328b5132/html5/thumbnails/19.jpg)
Add samehost and samenet designations to pg hba.conf
(Stef Walter)
# IPv4 local connections:
host all all 127.0.0.1/32 md5
host all all samehost md5
host all all samenet md5
![Page 20: Pdxpugday2010 pg90](https://reader034.vdocument.in/reader034/viewer/2022050801/554a5dd7b4c9054b328b5132/html5/thumbnails/20.jpg)
Log changed parameter values when postgresql.conf is
reloaded (Peter Eisentraut)
LOG: parameter "log_rotation_age" changed to "7d"
LOG: parameter "port" cannot be changed without restarting
LOG: parameter "log_rotation_age" changed to "1d"
LOG: parameter "log_min_messages" changed to "notice"
LOG: parameter "autovacuum" changed to "off"
<2010-04-22 14:00:50 PDT >LOG: parameter "log_line_prefix"
<2010-04-22 14:00:50 PDT >LOG: parameter "log_statement"
![Page 21: Pdxpugday2010 pg90](https://reader034.vdocument.in/reader034/viewer/2022050801/554a5dd7b4c9054b328b5132/html5/thumbnails/21.jpg)
Add an SQL state option (%e) to log line prefix
(Guillaume Smet)
e.g.:
log_line_prefix = ’<%t %d %u %e>’
gives you something like:
<2010-04-22 21:02:02 PDT postgres postgres 00000> \
LOG: statement: ALTER TABLE drop_column_demo DROP COLUMN
<2010-04-22 21:02:54 PDT postgres postgres 00000> \
LOG: statement: GRANT SELECT on drop_column_demo to groth;
<2010-04-22 21:02:54 PDT postgres postgres 42704> \
ERROR: role "groth" does not exist
![Page 22: Pdxpugday2010 pg90](https://reader034.vdocument.in/reader034/viewer/2022050801/554a5dd7b4c9054b328b5132/html5/thumbnails/22.jpg)
Add new EXPLAIN (BUFFERS) to report query buffer
activity (Itagaki Takahiro)
# EXPLAIN (ANALYZE, BUFFERS) SELECT * FROM
pg_attribute;
QUERY PLAN
--------------------------------------------------------------
Seq Scan on pg_attribute (cost=0.00..52.35 rows=1935 width=167)
(actual time=0.010..0.948 rows=1935 loops=1)
Buffers: shared hit=16 read=17
Total runtime: 1.841 ms
(3 rows)
selena@postgres:5432=# EXPLAIN (ANALYZE, BUFFERS) SELECT *
--------------------------------------------------------------
Seq Scan on pg_attribute (cost=0.00..52.35 rows=1935 width=167)
(actual time=0.010..0.589 rows=1935 loops=1)
Buffers: shared hit=33
Total runtime: 0.992 ms
![Page 23: Pdxpugday2010 pg90](https://reader034.vdocument.in/reader034/viewer/2022050801/554a5dd7b4c9054b328b5132/html5/thumbnails/23.jpg)
Allow EXPLAIN output in XML, JSON, and YAML
formats (Robert Haas, Greg Sabino Mullane)
EXPLAIN
SELECT * FROM user_history ORDER BY "timestamp";
QUERY PLAN
--------------------------------------------------------------
Sort (cost=18494.32..18852.33 rows=143204 width=34)
Sort Key: "timestamp"
-> Seq Scan on user_history (cost=0.00..2559.04 rows=143204
(3 rows)
![Page 24: Pdxpugday2010 pg90](https://reader034.vdocument.in/reader034/viewer/2022050801/554a5dd7b4c9054b328b5132/html5/thumbnails/24.jpg)
Con’t
EXPLAIN (FORMAT XML)
SELECT * FROM user_history ORDER BY "timestamp";
QUERY PLAN
------------------------------------------------------------
<explain xmlns="http://www.postgresql.org/2009/explain"> +
<Query> +
<Plan> +
<Node-Type>Sort</Node-Type> +
<Startup-Cost>18494.32</Startup-Cost> +
<Total-Cost>18852.33</Total-Cost> +
<Plan-Rows>143204</Plan-Rows> +
<Plan-Width>34</Plan-Width> +
<Sort-Key> +
<Item>"timestamp"</Item> +
</Sort-Key> +
...
![Page 25: Pdxpugday2010 pg90](https://reader034.vdocument.in/reader034/viewer/2022050801/554a5dd7b4c9054b328b5132/html5/thumbnails/25.jpg)
Con’t
...
<Plans> +
<Plan> +
<Node-Type>Seq Scan</Node-Type> +
<Parent-Relationship>Outer</Parent-Relationship>+
<Relation-Name>user_history</Relation-Name> +
<Alias>user_history</Alias> +
<Startup-Cost>0.00</Startup-Cost> +
<Total-Cost>2559.04</Total-Cost> +
<Plan-Rows>143204</Plan-Rows> +
<Plan-Width>34</Plan-Width> +
</Plan> +
</Plans> +
</Plan> +
</Query> +
</explain>
(1 row)
![Page 26: Pdxpugday2010 pg90](https://reader034.vdocument.in/reader034/viewer/2022050801/554a5dd7b4c9054b328b5132/html5/thumbnails/26.jpg)
Con’t
EXPLAIN (FORMAT YAML)
SELECT * FROM user_history ORDER BY "timestamp";
QUERY PLAN
-------------------------------------
- Plan: +
Node Type: Sort +
Startup Cost: 18494.32 +
Total Cost: 18852.33 +
Plan Rows: 143204 +
Plan Width: 34 +
Sort Key: +
- "\"timestamp\"" +
...
![Page 27: Pdxpugday2010 pg90](https://reader034.vdocument.in/reader034/viewer/2022050801/554a5dd7b4c9054b328b5132/html5/thumbnails/27.jpg)
Con’t
Plans: +
- Node Type: Seq Scan +
Parent Relationship: Outer +
Relation Name: user_history+
Alias: user_history +
Startup Cost: 0.00 +
Total Cost: 2559.04 +
Plan Rows: 143204 +
Plan Width: 34
(1 row)
![Page 28: Pdxpugday2010 pg90](https://reader034.vdocument.in/reader034/viewer/2022050801/554a5dd7b4c9054b328b5132/html5/thumbnails/28.jpg)
Add WHEN clause to CREATE TRIGGER to allow control
over whether a trigger is fired (Takahiro Itagaki)
CREATE TRIGGER name { BEFORE | AFTER } { event [ OR ... ] }
ON table [ FOR [ EACH ] { ROW | STATEMENT } ]
[ WHEN ( condition ) ]
EXECUTE PROCEDURE function_name ( arguments )
![Page 29: Pdxpugday2010 pg90](https://reader034.vdocument.in/reader034/viewer/2022050801/554a5dd7b4c9054b328b5132/html5/thumbnails/29.jpg)
Allow NOTIFY to pass an optional string to listeners
(Joachim Wieland)
lfnw-9.0=# LISTEN l9_0;
LISTEN
lfnw-9.0=# NOTIFY l9_0, ’need coffee...’;
NOTIFY
Asynchronous notification "l9_0"
with payload "need coffee..."
received from server process with PID 10480.
Also, now in-memory (faster!)
![Page 30: Pdxpugday2010 pg90](https://reader034.vdocument.in/reader034/viewer/2022050801/554a5dd7b4c9054b328b5132/html5/thumbnails/30.jpg)
Have columns defined with storage type MAIN remain on
the main heap page unless it cannot fit (Kevin Grittner)
8k page size
Before: a tuple might get TOAST’d prematurely
LIVE DEMO!
![Page 31: Pdxpugday2010 pg90](https://reader034.vdocument.in/reader034/viewer/2022050801/554a5dd7b4c9054b328b5132/html5/thumbnails/31.jpg)
Add pg stat reset single table counters() and
pg stat reset single function counters() to allow theresetting of statistics counters for individual tables andindexes (Magnus Hagander)
(Discuss.)
![Page 32: Pdxpugday2010 pg90](https://reader034.vdocument.in/reader034/viewer/2022050801/554a5dd7b4c9054b328b5132/html5/thumbnails/32.jpg)
Add pg last xlog receive location() and
pg last xlog replay location(), which can be used tomonitor standby server WAL activity (Simon, Fujii Masao,Heikki)
(Discuss.)
![Page 33: Pdxpugday2010 pg90](https://reader034.vdocument.in/reader034/viewer/2022050801/554a5dd7b4c9054b328b5132/html5/thumbnails/33.jpg)
Hot Standby/Streaming Replication
. . . drumroll . . .
![Page 34: Pdxpugday2010 pg90](https://reader034.vdocument.in/reader034/viewer/2022050801/554a5dd7b4c9054b328b5132/html5/thumbnails/34.jpg)
And now for something completely different...
Pg Android App Contest!
http://wiki.postgresql.org/wiki/AndroidAppContest
![Page 35: Pdxpugday2010 pg90](https://reader034.vdocument.in/reader034/viewer/2022050801/554a5dd7b4c9054b328b5132/html5/thumbnails/35.jpg)
Odds & Ends
VACUUM FULL is dead! Long live VACUUM FULL (likeCLUSTER).
Add deferrable unique constraints (Dean Rasheed)
vacuumdb –analyze-only (Bruce Momjian)
GRANT/REVOKE IN SCHEMA (Petr Jelinek)
pg table size and pg indexes size (Bernd Helmle)
Remove the use of flat files for system table bootstrapping(Tom, Alvaro)
DROP COLUMN IF EXISTS (Andreas Freund)
64-bit Windows support (Tsutomu Yamada, MagnusHagander)
Improvements to PL/Perl (Tim Bunce)
/contrib/passwordcheck (Laurenz Albe)
![Page 36: Pdxpugday2010 pg90](https://reader034.vdocument.in/reader034/viewer/2022050801/554a5dd7b4c9054b328b5132/html5/thumbnails/36.jpg)
Final Notes
These slides:
http://www.slideshare.net/selenamarie
Try it!
http://www.postgresql.org/ftp/source/9.0beta3/
http://www.postgresql.org/developer/beta
http://wiki.postgresql.org/wiki/HowToBetaTest
![Page 37: Pdxpugday2010 pg90](https://reader034.vdocument.in/reader034/viewer/2022050801/554a5dd7b4c9054b328b5132/html5/thumbnails/37.jpg)
Acknowledgements
Gabrielle RothMark WongMagnus HaganderHayley Jane Wakenshaw
__ __
/ \~~~/ \ . o O ( Thank you! )
,----( oo )
/ \__ __/
/| (\ |(
^ \ /___\ /\ |
|__| |__|-"
![Page 38: Pdxpugday2010 pg90](https://reader034.vdocument.in/reader034/viewer/2022050801/554a5dd7b4c9054b328b5132/html5/thumbnails/38.jpg)
License
This work is licensed under a Creative Commons Attribution 3.0Unported License. To view a copy of this license, (a) visithttp://creativecommons.org/licenses/by/3.0/us/; or, (b)send a letter to Creative Commons, 171 2nd Street, Suite 300, SanFrancisco, California, 94105, USA.