Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id EBC5F1337B2A for ; Wed, 22 Sep 2010 21:51:38 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 86348-05 for ; Thu, 23 Sep 2010 00:51:33 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-qy0-f181.google.com (mail-qy0-f181.google.com [209.85.216.181]) by mail.postgresql.org (Postfix) with ESMTP id 9DA2C1336971 for ; Wed, 22 Sep 2010 21:51:31 -0300 (ADT) Received: by qyk33 with SMTP id 33so1544814qyk.19 for ; Wed, 22 Sep 2010 17:51:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:references :in-reply-to:subject:date:message-id:mime-version:content-type :content-transfer-encoding:x-mailer:thread-index:content-language :x-cr-hashedpuzzle:x-cr-puzzleid; bh=w4U3A+O8bBzLR+o8qxp8BEXC3V1vf9reDz3scHk4wME=; b=dBmxu5SyyQMkNYvrazlASisd2Q/kXrPI+z2NhzLdoJUGxLVfH9rIWPeN77QHrlfrIW podkrFMptySMTJcs3U1LMHkOYp+VJ/03B8y6GzjMrW/s1sThhQcfou+rwjfGKZE/ccfX D0ddtuh3W/mkGODxFqFYTLH9pq5kRZhPZo2/U= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:references:in-reply-to:subject:date:message-id :mime-version:content-type:content-transfer-encoding:x-mailer :thread-index:content-language:x-cr-hashedpuzzle:x-cr-puzzleid; b=ZOmM9P3U+O0CgLxk9TZR4hiMN7gQ+FDiRJ8Uli2/3VgNB81T0SXKJoByrCKP6B3/oc M9eBe0eEDZBjrBY2N14tWnnxzYE4CpPcpTe8c4AZOHCbD9MrXkOdalqRmhBp6jJ0GCa1 SbgdRwYF/+9v8IUtohoCV89FqRIzrH+eWRI0s= Received: by 10.220.30.141 with SMTP id u13mr449572vcc.279.1285203091872; Wed, 22 Sep 2010 17:51:31 -0700 (PDT) Received: from Duality (174-16-121-37.hlrn.qwest.net [174.16.121.37]) by mx.google.com with ESMTPS id o24sm99987vcf.42.2010.09.22.17.51.29 (version=SSLv3 cipher=RC4-MD5); Wed, 22 Sep 2010 17:51:30 -0700 (PDT) From: "mark" To: "'Ozer, Pam'" , "'Robert Haas'" Cc: "'Craig James'" , References: <4C785B51.1020105@emolecules.com><216FFB77CBFAEE4B8EE4DF0A939FF1D1018247@mail-001.corp.automotive.com><216FFB77CBFAEE4B8EE4DF0A939FF1D101829E@mail-001.corp.automotive.com><216FFB77CBFAEE4B8EE4DF0A939FF1D10182A0@mail-001.corp.automotive.com> <216FFB77CBFAEE4B8EE4DF0A939FF1D10182A4@mail-001.corp.automotive.com> In-Reply-To: <216FFB77CBFAEE4B8EE4DF0A939FF1D10182A4@mail-001.corp.automotive.com> Subject: Re: Using Between Date: Wed, 22 Sep 2010 18:51:23 -0600 Message-ID: <004301cb5ab9$733565c0$59a03140$@com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: ActacwayJzQDn0BlR9STmMGaMQbDYAAACb8wABD4nXA= Content-Language: en-us x-cr-hashedpuzzle: Aytc GqZ5 M2wL Rn4a SI1r TOXD VTg4 W0CH a4KG eNXn eX86 fBZC g9a1 jWqC j2KY ohfi; 4; YwByAGEAaQBnAF8AagBhAG0AZQBzAEAAZQBtAG8AbABlAGMAdQBsAGUAcwAuAGMAbwBtADsAcABnAHMAcQBsAC0AcABlAHIAZgBvAHIAbQBhAG4AYwBlAEAAcABvAHMAdABnAHIAZQBzAHEAbAAuAG8AcgBnADsAcABvAHoAZQByAEAAYQB1AHQAbwBtAG8AdABpAHYAZQAuAGMAbwBtADsAcgBvAGIAZQByAHQAbQBoAGEAYQBzAEAAZwBtAGEAaQBsAC4AYwBvAG0A; Sosha1_v1; 7; {9089649A-69CD-4BFD-BFEE-BD4D512968D5}; ZAB2AGwAaABuAHQAcgBAAGcAbQBhAGkAbAAuAGMAbwBtAA==; Thu, 23 Sep 2010 00:51:15 GMT; UgBFADoAIABbAFAARQBSAEYATwBSAE0AXQAgAFUAcwBpAG4AZwAgAEIAZQB0AHcAZQBlAG4A x-cr-puzzleid: {9089649A-69CD-4BFD-BFEE-BD4D512968D5} X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201009/151 X-Sequence-Number: 40354 >>> The question is how can we make it faster. >>If there's just one region ID for any given postal code, you might try >>adding a column to vehicleused and storing the postal codes there. >>You could possibly populate that column using a trigger; probably it >>doesn't change unless the postalcode changes. Then you could index >>that column and query against it directly, rather than joining to >>PostalCodeRegionCountyCity. Short of that, I don't see any obvious >>way to avoid reading most of the vehicleused table. There may or may >>not be an index that can speed that up slightly and of course you can >>always throw hardware at the problem, but fundamentally reading half a >>million or more rows isn't going to be instantaneous. >>Incidentally, it would probably simplify things to store postal codes >>in the same case throughout the system. If you can avoid the need to >>write lower(x) = lower(y) and just write x = y you may get better >>plans. I'm not sure that's the case in this particular example but >>it's something to think about. Something else you might test is bumping the read-ahead value. Most linux installs have this at 256, might try bumping the value to ~8Meg and tune from there . this may help you slightly for seq scan performance. As always: YMMV. It's not going to magically fix low performing I/O subsystems and it won't help many applications of PG but there are a few outlying instances where this change can help a little bit. I am sure someone will step in and tell you it is a bad idea - AND they will probably have perfectly valid reasons for why it is, so you will need to consider the ramifications.. if at all possible test and tune to see. ..: Mark >>-- >>Robert Haas >>EnterpriseDB: http://www.enterprisedb.com >>The Enterprise Postgres Company -- >>Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) >>To make changes to your subscription: >>http://www.postgresql.org/mailpref/pgsql-performance