pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tim Cross <theophilusx@gmail.com>
To: kpi6288@gmail.com
Cc: pgsql-general@postgresql.org
Subject: Re: AW: CTE with JOIN of two tables is much faster than a regular query
Date: Sun, 19 Aug 2018 12:56:52 +1000
Message-ID: <87ftzb5aiz.fsf@gmail.com> (raw)
In-Reply-To: <007201d43711$33120e20$99362a60$@gmail.com>
References: <004b01d436d6$ff96c840$fec458c0$@gmail.com>
	<807123113.9511341.1534609514205@mail.yahoo.com>
	<007201d43711$33120e20$99362a60$@gmail.com>


kpi6288@gmail.com writes:

>> -----Ursprüngliche Nachricht-----
>> Von: Ravi Krishna <sravikrishna@aol.com>
>> Gesendet: Samstag, 18. August 2018 18:25
>> 
>> > What can I do to improve the performance of the regular query without
>> using a CTE?
>> 
>> Why do you care ?  When I find that I can write a SQL 3 different ways, I will
>> go for the most efficient one.  So why not accept the CTE version of this SQL.
>> Just curious.
>
> We're using object mapping / entity frameworks (e.g. XPO, Entity Framework Core). These frameworks support regular queries out-of-the box; a CTEs require additional effort and are more difficult to maintain. 
>

Ah, another reason to avoid object mapping/entity frameworks! I guess
really the same reason - loss of flexibility and expressive power.

Sorry, having a similar battle with some developers who are insisting on
using a particular framework because it makes maintenance easier as it
'automates' creation of controllers (MVC). However, they are frustrated
by performance and I'm frustrated as the framework also fails to pass
additional information, such as PGAPPNAME, which would make some
analysis easier. Part of the reason for the performance issues is
because the developers are doing things with result sets within the
client that would be far more efficient performed within the database.

One way I have resolved this in the past is to create database
procedures which present a 'mapped' view back to the framework layer
which hides the SQL from the framework. Works well, with the only main
downside being you now have SQL in a different (another) place, which
can make some people uncomfortable and can be a maintenance issue if all
your developers are just front-end devs who treat a database as just a
key/value repository. .

Tim
-- 
Tim Cross




view thread (7+ messages)  latest in thread

Message-ID: <87ftzb5aiz.fsf@gmail.com>
Permalink:  ../87ftzb5aiz.fsf@gmail.com/
Also on:    postgresql.org/message-id/87ftzb5aiz.fsf@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: theophilusx@gmail.com, kpi6288@gmail.com
  Subject: Re: CTE with JOIN of two tables is much faster than a regular query
  In-Reply-To: <87ftzb5aiz.fsf@gmail.com>
  References: <004b01d436d6$ff96c840$fec458c0$@gmail.com> <807123113.9511341.1534609514205@mail.yahoo.com> <007201d43711$33120e20$99362a60$@gmail.com> <87ftzb5aiz.fsf@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox