diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml
new file mode 100644
index 3d5f98b..37b838d
*** a/doc/src/sgml/libpq.sgml
--- b/doc/src/sgml/libpq.sgml
*************** PGconn *PQconnectdbParams(const char * c
*** 494,499 ****
--- 494,516 ----
           </listitem>
          </varlistentry>
  
+         <varlistentry id="libpq-connect-sslcompression" xreflabel="sslcompression">
+          <term><literal>sslcompression</literal></term>
+          <listitem>
+           <para>
+            If set to 1 (default), data sent over SSL connections will be
+            compressed if the SSL library supports it.  If set to 0,
+            compression will be disabled if the SSL library supports it.
+            This option is only available if <productname>PostgreSQL</>
+            is compiled with SSL support.
+           </para>
+           <para>
+            Note that setting <literal>sslcompression</> to 0 has no
+            effect on <productname>OpenSSL</> versions before 1.0.0.
+           </para>
+          </listitem>
+         </varlistentry>
+ 
          <varlistentry id="libpq-connect-sslcert" xreflabel="sslcert">
           <term><literal>sslcert</literal></term>
           <listitem>
*************** myEventProc(PGEventId evtId, void *evtIn
*** 6311,6316 ****
--- 6328,6343 ----
      <listitem>
       <para>
        <indexterm>
+        <primary><envar>PGSSLCOMPRESSION</envar></primary>
+       </indexterm>
+       <envar>PGSSLCOMPRESSION</envar> behaves the same as the <xref
+       linkend="libpq-connect-sslcompression"> connection parameter.
+      </para>
+     </listitem>
+ 
+     <listitem>
+      <para>
+       <indexterm>
         <primary><envar>PGSSLCERT</envar></primary>
        </indexterm>
        <envar>PGSSLCERT</envar> behaves the same as the <xref
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c
new file mode 100644
index ed9dce9..50f3f83
*** a/src/interfaces/libpq/fe-connect.c
--- b/src/interfaces/libpq/fe-connect.c
*************** static const PQconninfoOption PQconninfo
*** 222,227 ****
--- 222,230 ----
  	{"sslmode", "PGSSLMODE", DefaultSSLMode, NULL,
  	"SSL-Mode", "", 8},			/* sizeof("disable") == 8 */
  
+ 	{"sslcompression", "PGSSLCOMPRESSION", "1", NULL,
+ 	"SSL-Compression", "", 1},
+ 
  	{"sslcert", "PGSSLCERT", NULL, NULL,
  	"SSL-Client-Cert", "", 64},
  
*************** fillPGconn(PGconn *conn, PQconninfoOptio
*** 621,626 ****
--- 624,631 ----
  	conn->keepalives_count = tmp ? strdup(tmp) : NULL;
  	tmp = conninfo_getval(connOptions, "sslmode");
  	conn->sslmode = tmp ? strdup(tmp) : NULL;
+ 	tmp = conninfo_getval(connOptions, "sslcompression");
+ 	conn->sslcompression = tmp ? strdup(tmp) : NULL;
  	tmp = conninfo_getval(connOptions, "sslkey");
  	conn->sslkey = tmp ? strdup(tmp) : NULL;
  	tmp = conninfo_getval(connOptions, "sslcert");
diff --git a/src/interfaces/libpq/fe-secure.c b/src/interfaces/libpq/fe-secure.c
new file mode 100644
index 9c6ced6..f2bd9d0
*** a/src/interfaces/libpq/fe-secure.c
--- b/src/interfaces/libpq/fe-secure.c
*************** init_ssl_system(PGconn *conn)
*** 908,913 ****
--- 908,923 ----
  		 * causes unnecessary failures in nonblocking send cases.
  		 */
  		SSL_CTX_set_mode(SSL_context, SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER);
+ 
+ 		/*
+ 		 * If the OpenSSL version used supports it (from 1.0.0 on)
+ 		 * and the user requested it, disable SSL compression.
+ 		 */
+ #ifdef SSL_OP_NO_COMPRESSION
+ 		if (conn->sslcompression && conn->sslcompression[0] == '0') {
+ 			SSL_CTX_set_options(SSL_context, SSL_OP_NO_COMPRESSION);
+ 		}
+ #endif
  	}
  
  #ifdef ENABLE_THREAD_SAFETY
diff --git a/src/interfaces/libpq/libpq-int.h b/src/interfaces/libpq/libpq-int.h
new file mode 100644
index d56ef5d..64dfcb2
*** a/src/interfaces/libpq/libpq-int.h
--- b/src/interfaces/libpq/libpq-int.h
*************** struct pg_conn
*** 310,315 ****
--- 310,316 ----
  	char	   *keepalives_count;		/* maximum number of TCP keepalive
  										 * retransmits */
  	char	   *sslmode;		/* SSL mode (require,prefer,allow,disable) */
+ 	char	   *sslcompression;	/* SSL compression (0 or 1) */
  	char	   *sslkey;			/* client key filename */
  	char	   *sslcert;		/* client certificate filename */
  	char	   *sslrootcert;	/* root certificate filename */
