{"id":10994,"date":"2018-02-25T16:21:24","date_gmt":"2018-02-25T15:21:24","guid":{"rendered":"https:\/\/www.dbi-services.com\/blog\/configuring-huge-pages-for-your-postgresql-instance-debian-version\/"},"modified":"2018-02-25T16:21:24","modified_gmt":"2018-02-25T15:21:24","slug":"configuring-huge-pages-for-your-postgresql-instance-debian-version","status":"publish","type":"post","link":"https:\/\/www.dbi-services.com\/blog\/configuring-huge-pages-for-your-postgresql-instance-debian-version\/","title":{"rendered":"Configuring huge pages for your PostgreSQL instance, Debian version"},"content":{"rendered":"<p>In the <a href=\"https:\/\/www.dbi-services.com\/blog\/configuring-huge-pages-for-your-postgresql-instance-redhatcentos-version\/\" target=\"_blank\" rel=\"noopener\">last post<\/a> we had a look at how you can configure huge pages on RedHat and CentOS systems. For Debian and Debian based systems the procedure is different as Debian does not come with <a href=\"https:\/\/access.redhat.com\/documentation\/en-us\/red_hat_enterprise_linux\/7\/html-single\/performance_tuning_guide\/index#chap-Red_Hat_Enterprise_Linux-Performance_Tuning_Guide-Tuned\" target=\"_blank\" rel=\"noopener\">tuned<\/a>. Lets see how it works there.<\/p>\n<p><!--more--><\/p>\n<p>Checking the basic system configuration works the same in Debian as in RedHat based distributions by checking the \/proc\/meminfo file:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\npostgres@debianpg:\/home\/postgres\/ [PG1] cat \/proc\/meminfo | grep -i huge\nAnonHugePages:         0 kB\nShmemHugePages:        0 kB\nHugePages_Total:       0\nHugePages_Free:        0\nHugePages_Rsvd:        0\nHugePages_Surp:        0\nHugepagesize:       2048 kB\n<\/pre>\n<p>So nothing configured for huge pages in the default configuration. Using the same procedure from the <a href=\"https:\/\/www.dbi-services.com\/blog\/configuring-huge-pages-for-your-postgresql-instance-redhatcentos-version\/\" target=\"_blank\" rel=\"noopener\">last post<\/a> this is how you calculate the required huge pages for the PostgreSQL instance:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\npostgres@debianpg:\/home\/postgres\/ [PG1] head -1 $PGDATA\/postmaster.pid\n6661\npostgres@debianpg:\/home\/postgres\/ [PG1] grep ^VmPeak \/proc\/6661\/status\nVmPeak:\t  393836 kB\npostgres@debianpg:\/home\/postgres\/ [PG1] grep ^Hugepagesize \/proc\/meminfo\nHugepagesize:       2048 kB\npostgres@debianpg:\/home\/postgres\/ [PG1] echo \"393836\/2048\" | bc\n192\n<\/pre>\n<p>We&#8217;ll need at least 192 pages. Lets add that to \/etc\/sysctl.conf:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\npostgres@debianpg:\/home\/postgres\/ [PG1] sudo bash\nroot@debianpg:\/home\/postgres$ echo \"vm.nr_hugepages=200\" &gt;&gt; \/etc\/sysctl.conf\n<\/pre>\n<p>Notify the system about that change:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\nroot@debianpg:\/home\/postgres$ sysctl -p\nvm.nr_hugepages = 200\n<\/pre>\n<p>&#8230; and we have 200 huge pages available:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\npostgres@debianpg:\/home\/postgres\/ [PG1] cat \/proc\/meminfo | grep -i huge\nAnonHugePages:         0 kB\nShmemHugePages:        0 kB\nHugePages_Total:     200\nHugePages_Free:      200\nHugePages_Rsvd:        0\nHugePages_Surp:        0\nHugepagesize:       2048 kB\n<\/pre>\n<p>Again, lets force PostgreSQL to use huge pages and restart the instance:<\/p>\n<pre class=\"brush: sql; gutter: true; first-line: 1; highlight: [1,3]\">\npostgres@debianpg:\/home\/postgres\/ [PG1] psql -c \"alter system set huge_pages=on\" postgres\nALTER SYSTEM\npostgres@debianpg:\/home\/postgres\/ [PG1] pg_ctl -D $PGDATA restart -m fast\nwaiting for server to shut down.... done\nserver stopped\nwaiting for server to start....2018-02-25 17:13:59.398 CET [6918] LOG:  listening on IPv6 address \"::1\", port 5432\n2018-02-25 17:13:59.398 CET [6918] LOG:  listening on IPv4 address \"127.0.0.1\", port 5432\n2018-02-25 17:13:59.403 CET [6918] LOG:  listening on Unix socket \"\/tmp\/.s.PGSQL.5432\"\n2018-02-25 17:13:59.421 CET [6919] LOG:  database system was shut down at 2018-02-25 17:13:59 CET\n2018-02-25 17:13:59.427 CET [6918] LOG:  database system is ready to accept connections\n done\nserver started\n<\/pre>\n<p>&#8230; and that&#8217;s it:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\npostgres@debianpg:\/home\/postgres\/ [PG1] cat \/proc\/meminfo | grep -i huge\nAnonHugePages:         0 kB\nShmemHugePages:        0 kB\nHugePages_Total:     200\nHugePages_Free:      193\nHugePages_Rsvd:       64\nHugePages_Surp:        0\nHugepagesize:       2048 kB\n<\/pre>\n<p>We can do the same test as in the last post to check that the number of huge pages will increase when you have load on the system:<\/p>\n<pre class=\"brush: sql; gutter: true; first-line: 1\">\npostgres=# create table t1 as select * from generate_series(1,1000000);\nSELECT 1000000\npostgres=# select count(*) from t1;\n  count  \n---------\n 1000000\n(1 row)\n\npostgres=# ! cat \/proc\/meminfo | grep -i huge\nAnonHugePages:         0 kB\nShmemHugePages:        0 kB\nHugePages_Total:     200\nHugePages_Free:      184\nHugePages_Rsvd:       55\nHugePages_Surp:        0\nHugepagesize:       2048 kB\n<\/pre>\n<p>Btw: This is on Debian 9 (not sure if it is the same for lower versions):<\/p>\n<pre class=\"brush: sql; gutter: true; first-line: 1\">\npostgres@debianpg:\/home\/postgres\/ [PG1] cat \/etc\/os-release \nPRETTY_NAME=\"Debian GNU\/Linux 9 (stretch)\"\nNAME=\"Debian GNU\/Linux\"\nVERSION_ID=\"9\"\nVERSION=\"9 (stretch)\"\nID=debian\nHOME_URL=\"https:\/\/www.debian.org\/\"\nSUPPORT_URL=\"https:\/\/www.debian.org\/support\"\nBUG_REPORT_URL=\"https:\/\/bugs.debian.org\/\"\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>In the last post we had a look at how you can configure huge pages on RedHat and CentOS systems. For Debian and Debian based systems the procedure is different as Debian does not come with tuned. Lets see how it works there.<\/p>\n","protected":false},"author":28,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[229],"tags":[77],"type_dbi":[],"class_list":["post-10994","post","type-post","status-publish","format-standard","hentry","category-database-administration-monitoring","tag-postgresql"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v28.8 (Yoast SEO v28.8) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Configuring huge pages for your PostgreSQL instance, Debian version - dbi Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.dbi-services.com\/blog\/configuring-huge-pages-for-your-postgresql-instance-debian-version\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Configuring huge pages for your PostgreSQL instance, Debian version\" \/>\n<meta property=\"og:description\" content=\"In the last post we had a look at how you can configure huge pages on RedHat and CentOS systems. For Debian and Debian based systems the procedure is different as Debian does not come with tuned. Lets see how it works there.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.dbi-services.com\/blog\/configuring-huge-pages-for-your-postgresql-instance-debian-version\/\" \/>\n<meta property=\"og:site_name\" content=\"dbi Blog\" \/>\n<meta property=\"article:published_time\" content=\"2018-02-25T15:21:24+00:00\" \/>\n<meta name=\"author\" content=\"Open source Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Open source Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/configuring-huge-pages-for-your-postgresql-instance-debian-version\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/configuring-huge-pages-for-your-postgresql-instance-debian-version\\\/\"},\"author\":{\"name\":\"Open source Team\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/4bae5e5dd8c7d48edbd948772b49b202\"},\"headline\":\"Configuring huge pages for your PostgreSQL instance, Debian version\",\"datePublished\":\"2018-02-25T15:21:24+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/configuring-huge-pages-for-your-postgresql-instance-debian-version\\\/\"},\"wordCount\":188,\"commentCount\":0,\"keywords\":[\"PostgreSQL\"],\"articleSection\":[\"Database Administration &amp; Monitoring\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/configuring-huge-pages-for-your-postgresql-instance-debian-version\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/configuring-huge-pages-for-your-postgresql-instance-debian-version\\\/\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/configuring-huge-pages-for-your-postgresql-instance-debian-version\\\/\",\"name\":\"Configuring huge pages for your PostgreSQL instance, Debian version - dbi Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#website\"},\"datePublished\":\"2018-02-25T15:21:24+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/4bae5e5dd8c7d48edbd948772b49b202\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/configuring-huge-pages-for-your-postgresql-instance-debian-version\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/configuring-huge-pages-for-your-postgresql-instance-debian-version\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/configuring-huge-pages-for-your-postgresql-instance-debian-version\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Configuring huge pages for your PostgreSQL instance, Debian version\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/\",\"name\":\"dbi Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/4bae5e5dd8c7d48edbd948772b49b202\",\"name\":\"Open source Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/eb4fb12e386e8c41fdef0733e8114594cf2653e4f55e9fa2161442b8eaf3f657?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/eb4fb12e386e8c41fdef0733e8114594cf2653e4f55e9fa2161442b8eaf3f657?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/eb4fb12e386e8c41fdef0733e8114594cf2653e4f55e9fa2161442b8eaf3f657?s=96&d=mm&r=g\",\"caption\":\"Open source Team\"},\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/author\\\/open-source-team\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Configuring huge pages for your PostgreSQL instance, Debian version - dbi Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.dbi-services.com\/blog\/configuring-huge-pages-for-your-postgresql-instance-debian-version\/","og_locale":"en_US","og_type":"article","og_title":"Configuring huge pages for your PostgreSQL instance, Debian version","og_description":"In the last post we had a look at how you can configure huge pages on RedHat and CentOS systems. For Debian and Debian based systems the procedure is different as Debian does not come with tuned. Lets see how it works there.","og_url":"https:\/\/www.dbi-services.com\/blog\/configuring-huge-pages-for-your-postgresql-instance-debian-version\/","og_site_name":"dbi Blog","article_published_time":"2018-02-25T15:21:24+00:00","author":"Open source Team","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Open source Team","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.dbi-services.com\/blog\/configuring-huge-pages-for-your-postgresql-instance-debian-version\/#article","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/configuring-huge-pages-for-your-postgresql-instance-debian-version\/"},"author":{"name":"Open source Team","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/4bae5e5dd8c7d48edbd948772b49b202"},"headline":"Configuring huge pages for your PostgreSQL instance, Debian version","datePublished":"2018-02-25T15:21:24+00:00","mainEntityOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/configuring-huge-pages-for-your-postgresql-instance-debian-version\/"},"wordCount":188,"commentCount":0,"keywords":["PostgreSQL"],"articleSection":["Database Administration &amp; Monitoring"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.dbi-services.com\/blog\/configuring-huge-pages-for-your-postgresql-instance-debian-version\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.dbi-services.com\/blog\/configuring-huge-pages-for-your-postgresql-instance-debian-version\/","url":"https:\/\/www.dbi-services.com\/blog\/configuring-huge-pages-for-your-postgresql-instance-debian-version\/","name":"Configuring huge pages for your PostgreSQL instance, Debian version - dbi Blog","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/#website"},"datePublished":"2018-02-25T15:21:24+00:00","author":{"@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/4bae5e5dd8c7d48edbd948772b49b202"},"breadcrumb":{"@id":"https:\/\/www.dbi-services.com\/blog\/configuring-huge-pages-for-your-postgresql-instance-debian-version\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.dbi-services.com\/blog\/configuring-huge-pages-for-your-postgresql-instance-debian-version\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.dbi-services.com\/blog\/configuring-huge-pages-for-your-postgresql-instance-debian-version\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Accueil","item":"https:\/\/www.dbi-services.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Configuring huge pages for your PostgreSQL instance, Debian version"}]},{"@type":"WebSite","@id":"https:\/\/www.dbi-services.com\/blog\/#website","url":"https:\/\/www.dbi-services.com\/blog\/","name":"dbi Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/4bae5e5dd8c7d48edbd948772b49b202","name":"Open source Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/eb4fb12e386e8c41fdef0733e8114594cf2653e4f55e9fa2161442b8eaf3f657?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/eb4fb12e386e8c41fdef0733e8114594cf2653e4f55e9fa2161442b8eaf3f657?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/eb4fb12e386e8c41fdef0733e8114594cf2653e4f55e9fa2161442b8eaf3f657?s=96&d=mm&r=g","caption":"Open source Team"},"url":"https:\/\/www.dbi-services.com\/blog\/author\/open-source-team\/"}]}},"_links":{"self":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/10994","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/users\/28"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/comments?post=10994"}],"version-history":[{"count":0,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/10994\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media?parent=10994"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/categories?post=10994"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/tags?post=10994"},{"taxonomy":"type","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/type_dbi?post=10994"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}