Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.chainon-marquant.org!nntpfeed.proxad.net!proxad.net!feeder2-2.proxad.net!82.197.223.106.MISMATCH!feeder1.cambriumusenet.nl!feeder3.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.85.MISMATCH!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: 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; 'saying': 0.25; 'pm,': 0.26; 'stuff': 0.26; 'compare': 0.28; 'message-id:@mail.gmail.com': 0.28; '24,': 0.28; 'work:': 0.28; 'chris': 0.30; 'least': 0.30; 'tue,': 0.32; 'sort': 0.32; 'done': 0.33; 'to:addr:python-list': 0.33; 'eric': 0.34; 'list.': 0.34; 'anything': 0.34; "he's": 0.36; 'order.': 0.36; 'query': 0.36; 'but': 0.37; "there's": 0.37; 'received:google.com': 0.37; 'easiest': 0.38; 'some': 0.38; 'received:209.85': 0.38; 'useful': 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=S0zcvl7bGDjZuqo9mdM2TAWlildiai/bHC+JZ96AK90=; b=WXEOc+JsFS9juxnTiznNBI9rOsX9j6Hv+i6LFknXkEXuhl0HibqE95mCDqIKzWXZHO 9+YE7uNLJ0Zh//Z5QjhpRPNOfHb7PL/ez0WlyOuHJNz8OpYzJAk5bpjcsRQrhudIoEm1 qGZ1YxwV2YHG0vOea/miZjnmaeApv3xFq2Jn8= MIME-Version: 1.0 In-Reply-To: References: Date: Tue, 24 Jan 2012 19:30:16 +1100 Subject: Re: [GENERAL] [RFE] auto ORDER BY for SELECT From: Chris Angelico 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1327393819 news.xs4all.nl 6965 [2001:888:2000:d::a6]:59171 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:19330 Whoooooops. Wrong list. *sigh* At least there's some variety - it's not Savoynet this time. Disregard the mad guy in the corner, he's not saying anything useful anyway... ChrisA On Tue, Jan 24, 2012 at 7:29 PM, Chris Angelico wrote: > On Mon, Jan 23, 2012 at 11:17 PM, Douglas Eric 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