Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 55452632737 for ; Sat, 30 Jan 2010 11:04:48 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 33688-03 for ; Sat, 30 Jan 2010 15:04:28 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.kickstone.com (smtp.kickstone.com [87.194.183.70]) by mail.postgresql.org (Postfix) with ESMTP id 99732633FA0 for ; Sat, 30 Jan 2010 11:04:37 -0400 (AST) Received: from madras2.square-pi.com ([192.168.2.131]:4969 helo=MADRAS2) by mail.kickstone.com with esmtpa (Exim 4.69) (envelope-from ) id 1NbEsE-0008Qm-UM for pgsql-sql@postgresql.org; Sat, 30 Jan 2010 15:04:34 +0000 Message-ID: <855BA0CC16444AAAA11F11E6082B510A@squarepi.com> From: "John Lister" To: Subject: Re: Partitioning by letter question Date: Sat, 30 Jan 2010 15:04:34 -0000 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=response Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5843 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.273 tagged_above=-10 required=5 tests=AWL=-0.842, BAYES_00=-2.599, FAKE_REPLY_C=2.012, SUBJECT_FUZZY_TION=0.156 X-Spam-Level: X-Archive-Number: 201001/49 X-Sequence-Number: 33585 > wrote: >> Hi, I was wondering if this was possible. I'm trying to partition a table, >> which is straightforward enough thanks to the great documentation, but i >> have a question: >> >> If I partition using something like a product_id for example and have >> check >> constraints such as (id>=1000 and id<2000) then everything is fine and >> the >> planner correctly uses the right subset of the tables. However I would >> like >> to partition by the first letter and using something like this >> substr(word,1,1)='a' is ignored by the planner. From reading the docs I >> understand that complicated check constraints are ignored, but this >> doesn't >> seem overly complicated. >> >> Am i doing something wrong or is there another better way to do this >Have you tried: >(word >= 'a' and word <'b') Cheers, had my programming head on. One question: any ideas about what to put for the last in the list i thought something like (word>='z' and word<'{') which is based on the ascii ordering. - my db is using utf8 I tried to check this by doing select * from words where word >'zzzz' order by word limit 10; which returns '.' as the first result (ok not a word, but that is a different issue) but if i do select * from words where word <'.' order by word desc limit 10 I get '/...' as the first result, I would expect 'zzzz', this doesn't seem consistent. I'm obviously missing some inherent sorting behaviour her, but not sure.. Thanks John