Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UQe4i-0003QZ-BL for pgsql-sql@arkaria.postgresql.org; Fri, 12 Apr 2013 13:31:32 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UQe4h-0007yJ-MP for pgsql-sql@arkaria.postgresql.org; Fri, 12 Apr 2013 13:31:31 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UQe4g-0007y4-PY for pgsql-sql@postgresql.org; Fri, 12 Apr 2013 13:31:30 +0000 Received: from plane.gmane.org ([80.91.229.3]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UQe4a-0000Ky-Kf for pgsql-sql@postgresql.org; Fri, 12 Apr 2013 13:31:30 +0000 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UQe4Z-00086T-SJ for pgsql-sql@postgresql.org; Fri, 12 Apr 2013 15:31:23 +0200 Received: from ip-118-90-25-130.xdsl.xnet.co.nz ([118.90.25.130]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 12 Apr 2013 15:31:23 +0200 Received: from jasen by ip-118-90-25-130.xdsl.xnet.co.nz with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 12 Apr 2013 15:31:23 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-sql@postgresql.org From: Jasen Betts Subject: Re: Advice for index design Date: 12 Apr 2013 13:29:39 GMT Organization: Dis (not Dat) Organisation Lines: 19 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: ip-118-90-25-130.xdsl.xnet.co.nz X-Face: ?)Aw4rXwN5u0~$nqKj`xPz>xHCwgi^q+^?Ri*+R(&uv2=E1Q0Zk(>h!~o2ID@6{uf8s; a +M[5[U[QT7xFN%^gR"=tuJw%TXXR'Fp~W; (T"1(739R%m0Yyyv*gkGoPA.$b,D.w:z+<'"=-lVT?6 {T?=R^:W5g|E2#EhjKCa+nt":4b}dU7GYB*HBxn&Td$@f%.kl^:7X8rQWd[NTc"P"u6nkisze/Q; 8 "9Z{peQF,w)7UjV$c|RO/mQW/NMgWfr5*$-Z%u46"/00mx-,\R'fLPe.)^ User-Agent: slrn/pre1.0.0-18 (Linux) X-Pg-Spam-Score: -4.3 (----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org On 2013-04-10, JORGE MALDONADO wrote: > Our application offers a catalog of artists where a user can select a range > of birthdays and/or sex. For example, a user can get an artists catalog for > those male artists who were born between May 1, 1970 and May 1, 1990 > ordered by birthday and, within each birthday date, ordered by name. I can > think of defining one index for birthday, one index for name, and one index > for sex. Also, I can think of defining a compound index for birthday + > name. Also there could be a compound index for sex + name. Another option > could be a compound index for birthday + sex + name. There are many > possible combinations. What is a good index design approach? the best approach depends on where you need the most improvement. For your example query an undex on (sex,birthday,name) would be best. -- ⚂⚃ 100% natural -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql