Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #19329

Re: [GENERAL] [RFE] auto ORDER BY for SELECT

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:: [': 0.02; 'distinct': 0.05; 'behavior.': 0.07; "(it's": 0.09; '(there': 0.09; 'any.': 0.09; 'exceptions': 0.09; 'query,': 0.09; 'received:209.85.210.174': 0.13; 'received:mail- iy0-f174.google.com': 0.13; 'mon,': 0.15; 'analyze,': 0.16; 'disregard': 0.16; 'distinct,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject:] [': 0.16; 'subject:auto': 0.16; 'versus': 0.16; 'subject:] ': 0.16; 'wrote:': 0.16; 'jan': 0.19; 'suggest': 0.20; 'header:In-Reply- To:1': 0.22; 'statement': 0.23; 'douglas': 0.23; 'etc,': 0.23; 'pm,': 0.26; 'stuff': 0.26; 'compare': 0.28; 'message- id:@mail.gmail.com': 0.28; 'work:': 0.28; 'least': 0.30; 'sort': 0.32; 'done': 0.33; 'to:addr:python-list': 0.33; 'eric': 0.34; 'order.': 0.36; 'query': 0.36; 'but': 0.37; 'received:google.com': 0.37; 'easiest': 0.38; 'received:209.85': 0.38; 'primary': 0.38; 'possible.': 0.39; 'why': 0.39; 'received:209': 0.39; 'change': 0.40; 'to:addr:python.org': 0.40; 'order': 0.60; 'more': 0.61; 'results': 0.64; 'genuine': 0.68; 'care': 0.70; 'union': 0.72; "'em": 0.84; 'often,': 0.84; '-->': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=SfqYO79PCrOLrbQszuDEj2WkC8bkbkxOwcNMua9bEvE=; b=pbkLqC5UmmHqv6/d1lnkkXPibr1DQ2oKd0fR73HWqfUBQ9R9vguX2tP1bBOXcUls/Z hbU0y/jJ5ofa4wzzKcq/utjg7kKMpqO1w7O75XnOj5DLv7S9a4zwvJVS3H4me03nNIYr QmHq1UPMcLYZ0ZFNXWu4w9X51lrRnu42Af8XE=
MIME-Version 1.0
In-Reply-To <BLU166-W49985900AC6AEE6E60290DBF8A0@phx.gbl>
References <BLU166-W49985900AC6AEE6E60290DBF8A0@phx.gbl>
Date Tue, 24 Jan 2012 19:29:05 +1100
Subject Re: [GENERAL] [RFE] auto ORDER BY for SELECT
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.5018.1327393748.27778.python-list@python.org> (permalink)
Lines 22
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1327393748 news.xs4all.nl 6897 [2001:888:2000:d::a6]:57601
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:19329

Show key headers only | View raw


On Mon, Jan 23, 2012 at 11:17 PM, Douglas Eric <sekkuar@hotmail.com> wrote:
> I suggest to change this behavior. If one makes a SELECT statement without
> any ORDER BY, it would be
> clever to automatically sort by the first primary key found in the query, if
> any.
> The present behavior would still be used in case of queries without any
> primary key fields.

This would require that work be done without text commanding it, which
is IMHO a bad idea. Generally, SQL follows the principle that more
text --> more work: compare SELECT and SELECT DISTINCT (it's more work
to look for duplicates), VACUUM and VACUUM ANALYZE, etc, etc. The
default state is to do the least work that makes sense. (There are
exceptions - UNION ought to be UNION DISTINCT, versus UNION ALL to
reduce the work done - but this is the general rule.)

Often, a query is done with genuine disregard for order. If you're
going to take the results of the query and stuff them into a
hashtable, you don't care what order they come up in. Why have the
database sort them? Let 'em come in the easiest order possible.

ChrisA

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: [GENERAL] [RFE] auto ORDER BY for SELECT Chris Angelico <rosuav@gmail.com> - 2012-01-24 19:29 +1100

csiph-web