Re: Order By Clause, Slows Query Performance? - Mailing list pgsql-performance

From Michael Paquier
Subject Re: Order By Clause, Slows Query Performance?
Date
Msg-id CAB7nPqQUX2y1Hzossg2X1LBiLXiyHO502D95CPU6hT7Q=Hd=7g@mail.gmail.com
Whole thread Raw
In response to Order By Clause, Slows Query Performance?  (monalee_dba <monalee@sungraceinfotech.co.in>)
List pgsql-performance
On Sun, Nov 10, 2013 at 4:40 PM, monalee_dba
<monalee@sungraceinfotech.co.in> wrote:
> Eg. SELECT col1, col2, col3,....col10 FROM table1;
>
> For above query If I didn't mention ORDER BY clause, then I want to know
> selected data will appear in which order by a query planner?
The data will be selected in the order at which it is scanned.

> Because I have huge size table, and when I applied ORDER BY col1, col2..in
> query the
> performance is soo bad that I can't offred.
> What should I do ? Because my requirement is data with ordered column.
Redesign your application. The larger your relation "table1" would
get, the more data you would fetch and the slower it would get. The
best advice I got here would be first to analyze why you need to fetch
that much data back to your application. Particularly, if your
application fetches that much data and post-treats it internally, you
should try to maximize such processing on the database server side and
not the application side to minimize the amount of data exchanged
between the database server and the application client.

Note that you might as well consider changing your schema.
--
Michael


pgsql-performance by date:

Previous
From: Michael Paquier
Date:
Subject: Re: BitMap Heap Scan & BitMap Index Scan
Next
From: Tom Lane
Date:
Subject: Re: Performance bug in prepared statement binding in 9.2?