Re: Python versus Other Languages using PostgreSQL

From: Steve Crawford <scrawford(at)pinpointresearch(dot)com>
To: Paul Hughes <paul(at)vivation(dot)com>
Cc: PG-General Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: Python versus Other Languages using PostgreSQL
Date: 2017-05-09 17:19:39
Message-ID: CAEfWYyzVwskoXEHCaiGS7+RSa2ETtvUAZAVGbqLgpUkuAUrtcg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, May 8, 2017 at 2:26 PM, Paul Hughes <paul(at)vivation(dot)com> wrote:

> Hello,
>
> I noticed that most of the largest web platforms that use PostgreSQL as
> their primary database, also use Python as their primary back-end language.
> Yet, according to every benchmark I could find over the last couple of
> years, back-end languages like PHP, HHVM, and Node.JS outperform Python by
> 2x to 8x!
>

This is a questionable and incomplete starting point starting with a vague
assertion lacking a reasonable set of examples.

You are conflating languages (PHP, Python) with various environments in
which they run (the Node.js runtime for Javascript and HHVM virtual machine
for PHP/Hack), failing to provide version/implementation/acceleration
information of the languages (Zend, PyPy,), and failing to state anything
about the environment: Is it raw code or are we actually discussing
framework performance? What are other requirements/constraints on the
overall system?

Picking a single data-point (speed) of a single part of a system (back end
language) is not typically informative. There is speed of development,
availability of developers, feature sets, robustness, licensing,
availability of commercial support, security issues and ability to
integrate with other parts of a corporate environment to name just a few.
The impact of the language speed may be minuscule compared to the impact of
other aspects of the overall system. One could as easily ask, "Why do so
many people use PHP when assembler is so much faster?"

If speed is the only requirement you can get a great boost in PostgreSQL by
turning off fsync. Of course you may lose all your data in a crash but,
hey, it's faster!

To quote our own illustrious Tom Lane:

"...Try to carry 500 people from Los Angeles to Tokyo in an F-15. No? Try
to win a dogfight in a 747. No? But they both fly, so it must be useful to
compare them... especially on the basis of the most simplistic test case
you can think of. For extra points, use *only one* test case. Perhaps
this paper can be described as "comparing an F-15 to a 747 on the basis of
required runway length...".

To really determine the answer you would have to ask each one why they
chose their specific combination of language(s) database, OS, hardware/VM,
caching, pooling, etc.; what they would do differently in retrospect and
also evaluate the validity of those decisions. For the most part we, here,
can only guess.

> So here are my questions:
>
> 1) Why do the largest web applications that use PostgreSQL also use
> Python, even though Python is significantly slower than it's biggest
> competitors?
>

See comments above.

>
> 2) Can PostgreSQL just as easily be used with PHP or Node.js? If not, why
> not?
>
>
Yes. We have PHP, Python, Ruby, C, Bash (via psql), Perl, LibreOffice, etc.
directly connecting to our server. There is also client support for Java,
.NET, Tcl, C++, ODBC, Erlang, Haskell, Lua, R, Smalltalk, ...

> 3) Can PostgreSQL be made to work seamlessly to take advantage of the
> superior performance of HHVM or Node.js?
>

See above.

>
>
> Thank you in advance!
>
> ~Paul
>
>
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon> Virus-free.
> www.avast.com
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=link>
> <#m_7020864994226728918_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Rajesh Mallah 2017-05-09 18:50:18 logging of application level user in audit trigger
Previous Message Armand Pirvu (home) 2017-05-09 14:56:59 Re: data transformation and replication