Skip to content

Commit

Permalink
Merge pull request #143 from engineyard/pg_stat_statements
Browse files Browse the repository at this point in the history
properly installs pg_stat_statements extension
  • Loading branch information
dennisjbell committed Mar 13, 2015
2 parents 8a107b6 + 7d2d1b6 commit 4f6adf5
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 8 deletions.
15 changes: 8 additions & 7 deletions cookbooks/main/recipes/default.rb
Expand Up @@ -139,10 +139,10 @@
# postgresql9_pg_trgm "dbname"
# postgresql9_pgcrypto "dbname"
# postgresql9_pgrowlocks "dbname"

# PostGis 1.5 (use with versions 9.0, 9.1, 9.2)
# postgresql9_postgis "dbname"

# PostGis 2.0 (use with versions >= 9.2)
#postgresql9_postgis2 "dbname"
# postgresql9_seg "dbname"
Expand All @@ -151,15 +151,16 @@
# postgresql9_test_parser "dbname"
# postgresql9_unaccent "dbname"
# postgresql9_uuid_ossp "dbname"


# 9.1 and 9.2 Extensions
# postgresql9_file_fdw "dbname"
# postgresql9_xml2 "dbname"

#9.2 Extensions

# 9.2 Extensions
# Note: pg_stat_statements requires a server restart to complete installation
# postgresql9_pg_stat_statements "dbname"

# Admin-Level Contribs
# postgresql9_pg_buffercache "postgres"
# postgresql9_pg_freespacemap "postgres"
Expand Down
12 changes: 12 additions & 0 deletions cookbooks/postgresql9_extensions/README.md
Expand Up @@ -246,6 +246,18 @@ extension applied to.

``postgresql9_pgrowlocks "dbname""``

##pg_stat_statements
###supported versions: 9.2 - Note that pg_stat_statements requires a server restart to complete installation

The pg_stat_statements module provides a means for tracking execution statistics of all SQL statements executed by a server.

Enabling this extension:

* Edit main/recipes/default.rb and comment out the line shown below. Replace dbname with the name of the database you want this
extension applied to.

``postgresql9_pg_stat_statements "dbname""``

##PostGIS 1.5
###supported versions: >= 9.0
This extension adds support for geographic objects. PostGIS "spatially enables" the PostgreSQL server, allowing it to be used as a backend spatial database for geographic information systems (GIS).
Expand Down
15 changes: 15 additions & 0 deletions cookbooks/postgresql9_extensions/definitions/pg_stat_statements.rb
Expand Up @@ -6,4 +6,19 @@
extname "pg_stat_statements"
minimum_version 9.2
end

#add shared_preload_libraries and pg_stat_statements to custom pgconf
p = "/db/postgresql/#{@node[:postgres_version]}/custom.conf"
ext_name = "pg_stat_statements"
update_file "add #{ext_name} to #{p}" do
action :append
path p
body <<-EOF
shared_preload_libraries = 'pg_stat_statements'
pg_stat_statements.max = 10000
pg_stat_statements.track = all
EOF
not_if "grep '#{ext_name}' #{p}"
end
end
Expand Up @@ -24,7 +24,7 @@
})
end

execute "restarting postgres service" do
execute "reload postgres service" do
command "/etc/init.d/postgresql-#{@node[:postgres_version]} reload"
end

0 comments on commit 4f6adf5

Please sign in to comment.