If you can't read please download the document
Upload
andrew-dunstan
View
1.943
Download
1
Embed Size (px)
Citation preview
2. Topics
3. PostgreSQL general features (briefly) 4. PostgreSQL 8.4 features
5. See the release notes A few looks at what's in the pipeline 6. Untopics
7. Should the name be PostgreSQL or Postgres? 8. GPL vs BSD 9. Four legsUnix good,two legsWindows bad 10. emacs vs. vi 11. GUI vs command line 12. ... 13. Play along
14. tar -j -xf postgresql-8.4.1.tar.bz2 15. cd postgresql-8.4.1 16. ./configure prefix=`pwd`/../pg84--with-pgport=5678 17. make && make install && cd contrib && make && make install 18. Who uses PostgreSQL?
19. myyearbook 20. Skype 21. Etsy 22. New York Post 23. Afilias 24. Whitepages.com
25. IMDB 26. Rockport 27. Apple 28. NTT 29. Cisco 30. National Weather Service 31. What uses PostgreSQL?
32. Wikipedia 33. Drupal 34. Bricolage 35. OpenACS 36. Gforge 37. xTuple/OpenRPT
38. Serendipity 39. PostGIS 40. OpenStreetMap 41. Reddit 42. Trac 43. LedgerSMB 44. PostgreSQL history Original Postgres project started at Berkeley 1986 by Michael Stonebraker SQL added in 1995 Current community project dates from 1996 Several developers from then still active, e.g.Bruce Momjian 45. PostgreSQL License
46. Nobody owns the code, anyone can use the code 47. No monopoly 48. PostgreSQL philosophy
49. Safety 50. Correctness 51. Robustness 52. Standards compliance 53. Performance 54. PostgreSQL Features
55. Writers don't block readers Extensive and extensible type system 56. Joins and Subqueries 57. Foreign keys 58. Namespaces (schemas) 59. Triggers 60. More PostgreSQL features
61. Plpgsql
plPerl, plTcl, plPython, plRuby, plJava, plR, ..... Standard modules
Transactional DDL 62. Point In Time Recovery 63. PostgreSQL 8.4
64. 17 months in development 65. Over 200 new features and improvements 66. PostgreSQL 8.4 killer features
67. Window Functions 68. Parallel Restore 69. PostgreSQl 8.4 GBH features
70. Variadic functions 71. Per database locales 72. Significant performance improvements 73. Version aware psql command 74. Common Table Expressions
with t as ( select a,b,c from foo ) select * from t; 75. with t as ( select a,b,c from foo ), s as (select a,d,e from bar) select b,d from t,s where t.a=s.a; 76. Recursive CTEs
77. 354224848179261915075 78. Transitive closure with CTEs
79. Forget nested sets similar monstrosities 80. Interesting effects with CTEs create or replace function hanoi(discs integer, move out integer, a out int[], b out int[], c out int[]) returns setof record language sql as $$ with recursive han as ( select 1::int as move, $1 as ndiscs, '{99}'::int[] || array_agg(discs)as a, '{99}'::int[] as b, '{99}'::int[] as c from generate_series($1,1,-1) as discs union all select move + 1 , ndiscs, hnext(move, ndiscs, a,b,c), hnext(move, ndiscs, b,c,a), hnext(move, ndiscs, c,a,b) from han where array_length(b,1) < ndiscs + 1 ) select move, a[2:$1+1] as a, b[2:$1+1] as b, c[2:$1+1] as c from han order by move $$; Select * from hanoi(4); 81. Results: move |a|b|c------+-----------+-----------+--------- 1 | {4,3,2,1} | {}| {} 2 | {4,3,2}| {}| {1} 3 | {4,3}| {2}| {1} 4 | {4,3}| {2,1}| {} 5 | {4}| {2,1}| {3} 6 | {4,1}| {2}| {3} 7 | {4,1}| {}| {3,2} 8 | {4}| {}| {3,2,1} 9 | {}| {4}| {3,2,1} 10 | {}| {4,1}| {3,2} 11 | {2}| {4,1}| {3} 12 | {2,1}| {4}| {3} 13 | {2,1}| {4,3}| {} 14 | {2}| {4,3}| {1} 15 | {}| {4,3,2}| {1} 16 | {}| {4,3,2,1} | {} (16 rows) 82. Sneak Peak: CTE's in 8.5
83. And similar for insert and update queries 84. Window functions
85. Similar to aggregates, but does not collapse rows 86. All aggregate functions can be used as window functions 87. Window function examples
88. select *, row_number() over t as rownum from bar window t as (order by foo) order by foo 89. (you can omit the outer order by, but it's best not to). 90. More window function examples
91. Major missing SQL features
92. merge 93. Parallel pg_restore
94. Only works with custom format dumps 95. Uses specified number of connections to the database 96. Especially useful for partitioned databases 97. Typical speedup is around number_of_processors/2 98. Sweet spot is between number_of_processors and 2 *number_of_processors 99. Parallel pg_restore continued
100. Individual steps are not parallelized 101. Uses dependency information to make sure steps are done in right order 102. Parallel clients are forked processes on *nix, threads on Windows 103. pg_restore -d dbname -j 4 dumpfile 104. Parallel pg_restore TODO
105. Parallel pg_dump
106. Needs new archive format (directory) Parallel COPY, index build 107. A small digression
108. All being addressed 109. First monkey on our back
Parallel pg_restore some help 110. Two efforts underway ... 111. Core team committed to providing less painful upgrade mechanisms
112. Replication
113. Three forms:
114. Data replay via triggers
115. Can cause foreign key constraint problems Log shipping
116. Transparent to applications 117. The second monkey on our back
8.5 feature (nearly): Streaming Replication
118. New special built in WALsender daemon 119. After initial backup (rsync) all managed via config file settings 120. Streams log records rather than waiting for complete WAL files much lower latency 121. Third monkey on our back
122. Many users thus have a combination of log shipping and trigger based replicas 8.5 feature (nearly): Hot Standby
123. Ideal for a report server, decision support etc. 124. Take load off transaction processing system 125. Significant features
126. Column level privileges
127. Previously only way to do this was via a view 128. In SQL Standard 129. Locales
130. Can be set at time ofcreatedbinstead ofinitdb 131. Ultimate goal is to be able to set locale and charset / encoding for each column
132. Performance improvements
133. This trigger inhibits the update if the new and old records are identical 134. Very fast (uses memcmp() on whole data area) 135. Break even point is at worst around 30%, i.e. you're better off using it if more than 30% of the updates are in fact redundant. 136. Also save vacuuming etc. 137. Performance improvements continued
free space map fork
138. No more config settings required Infrastructure exists for other such forks if required. Hash indexes now much faster
139. SQL Features - Arrays
unnest()
140. Opposite of array_agg() 141. SQL Features - Views
142. SQL Features limit/offset
143. SQL Standard syntax now supported:
144. FETCH { FIRST | NEXT } [ count ] { ROW | ROWS } ONLY 145. Function features
146. SELECT min($1[i]) FROM generate_subscripts($1, 1) g(i); 147. $$ LANGUAGE SQL; select mleast(1,4,9,-6,2,5); 148. Result: -6 149. More Function features
150. Previously required overloading to get same effect. 151. PL/PGSQL features
CASE statement 152. psql features
ef function_name 153. Questions?