Received: from sss.pgh.pa.us ([192.204.191.242]) by postgresql.org (8.11.3/8.11.4) with ESMTP id fBSF5Cm99568 for ; Fri, 28 Dec 2001 10:05:12 -0500 (EST) (envelope-from tgl@sss.pgh.pa.us) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.11.4/8.11.4) with ESMTP id fBSF4Zj00716; Fri, 28 Dec 2001 10:04:35 -0500 (EST) To: Heni Lolov cc: pgsql-admin@postgresql.org Subject: Re: indexes bug or feature In-reply-to: <20011228111603.47764.qmail@web21003.mail.yahoo.com> References: <20011228111603.47764.qmail@web21003.mail.yahoo.com> Comments: In-reply-to Heni Lolov message dated "Fri, 28 Dec 2001 03:16:03 -0800" Date: Fri, 28 Dec 2001 10:04:35 -0500 Message-ID: <713.1009551875@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200112/157 X-Sequence-Number: 2880 You don't need to post questions four times ;-) Heni Lolov writes: > I have folowing table > create table usno( > reg_id int2, > id int2, > ra int4, > de int4, > mag_r int2, > mag_b int2 > ); > I make indexes in this order: > create index usno_drm_r on gsc_act(de,ra,mag_r); > create index usno_drm_b on gsc_act(de,ra,mag_b); > the problem is: > when I search on "de","ra" and "mag_b" or "de", "ra" > and "mag_r" Postgres uses always "usno_drm_r". > If I create the indexes in reversed order > "usno_drm_b" is always used. I bet that it's only using the first two columns of the index, so that it doesn't really matter which index is used. Are you being careful to cast the values compared to mag_r or mag_b to int2? "mag_r = 42" isn't indexable because 42 is an int4. regards, tom lane