From: Stefan Stefanov <stefanov.sm@abv.bg>
To: Francisco Olarte <folarte@peoplecall.com>
Cc: \"\"\"\"\"pgsql-bugs@postgresql.org\"\"\"\"\" <pgsql-bugs@postgresql.org>
Subject: Re: BUG #14491: Huge delay when specifying certain column names to select list expressions
Date: Wed, 11 Jan 2017 21:32:31 +0200 (EET)
Message-ID: <550419838.46005.1484163151769.JavaMail.apache@nm33.abv.bg> (raw)
In-Reply-To: <CA+bJJbzqoO9b4z38BZu=HBHU7SHZgeFAC2=y8WiCuzQQhAQOnQ@mail.gmail.com>
References: <20170111131022.24286.18735@wrigleys.postgresql.org>
<CA+bJJbzqoO9b4z38BZu=HBHU7SHZgeFAC2=y8WiCuzQQhAQOnQ@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
Dear Francisco, team,
Thanks, absolutely right. Please excuse my omission.
Table field "data_in.ioground.tovaritelnica" is an index key. Therefore the first and third queries use it for 'order by' while the second does not since AS conceals the field name and the function call surely defeats the index.
Sincerely,
Stefan
>-------- Оригинално писмо --------
>От: Francisco Olarte folarte@peoplecall.com
>Относно: Re: [BUGS] BUG #14491: Huge delay when specifying certain column
names to select list expressions
>До: stefanov.sm@abv.bg
>Изпратено на: 11.01.2017 17:39
On Wed, Jan 11, 2017 at 2:10 PM, stefanov.sm@abv.bg > wrote:
> The following bug has been logged on the website:
> This is a real life example - a simple function that makes text CP1251-safe
> and 3 trivial queries. The first one is a test to determine whether the
> function incurs significant performance penalty (it does not). Execution
> time was 218 ms.
> Having specified explicit names to the select list expressions (these names
> are the same as the names of the underlying columns) execution time soared
> to 9.1 sec.
> The third query is the same as the second one except that the given
> expression names are not the same as the names of the underlying columns.
> The execution time was back again to the comfortable 219 ms.
It seems to me your 1st and 3rd queries are the same, the 2nd is not,
as order by uses the expresion, not the field, "tovaritelnica". (
https://www.postgresql.org/docs/9.2/static/sql-select.html#SQL-ORDERBY
: "Each expression can be the name or ordinal number of an output
column (SELECT list item), or it can be an arbitrary expression formed
from input-column values." )
1St:
> SELECT
... Output column
> data_in.clear_cp1251(tovaritelnica),
...
> ORDER BY tovaritelnica DESC
.. But ordered by field ( an expression ), as column is no named like it.
2Nd.
> SELECT
...
> data_in.clear_cp1251(tovaritelnica) AS tovaritelnica,
...
> ORDER BY tovaritelnica DESC
Now ordering by output column, it shadows the name.
3Rd:
> SELECT
...
> data_in.clear_cp1251(tovaritelnica) AS _tovaritelnica,
....
> ORDER BY tovaritelnica DESC
Again, ordering by expresion => field, no column.
Try specifying the column name as "data_in.ioground.tovaritelnica" in
the order by, or something similar. But remember 1st and 3rd query
select one thing but order by a different one.
Francisco Olarte.
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-bugs@postgresql.org
Cc: stefanov.sm@abv.bg, folarte@peoplecall.com
Subject: Re: BUG #14491: Huge delay when specifying certain column names to select list expressions
In-Reply-To: <550419838.46005.1484163151769.JavaMail.apache@nm33.abv.bg>
References: <20170111131022.24286.18735@wrigleys.postgresql.org> <CA+bJJbzqoO9b4z38BZu=HBHU7SHZgeFAC2=y8WiCuzQQhAQOnQ@mail.gmail.com> <550419838.46005.1484163151769.JavaMail.apache@nm33.abv.bg>
* 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