Re: Suitable Index for my Table

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Janek Sendrowski <janek12(at)web(dot)de>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Suitable Index for my Table
Date: 2013-11-04 22:30:25
Message-ID: 20131104223025.GC3552@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Nov 04, 2013 at 10:44:29PM +0100, Janek Sendrowski wrote:
> I am always searching for single colums. The  values are different every time, because these are distances from my new sentence to my pivots.
> Does the Index support a query with this WHERE statement: WHERE value BETWEEN (distance1 - radius) AND (distance1 + radius)?

Ok, this is not consistant. You say you're only searching single
columns, but in your example query you're doing 23 columns in one
query.

> A working query looks like this:
> SELECT id FROM distance WHERE
> value BETWEEN (distance1 - radius) AND (distance1 + radius) AND
> value BETWEEN (distance2 - radius) AND (distance2 + radius) AND
> value BETWEEN (distance3 - radius) AND (distance3 + radius) AND

So you're looking for the same value amongst all distances? That's
doesn't seem very useful. Then if distance1=0 and distance2=1 and
radius=0.2 then this query will never match that row, no matter what
value of value.

Anyway, unless you can describe this problem as something geometric
(such that you can consider it a search for overlapping cubes) I'd do
what the other post suggests and just put a btree index on every
column.

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> He who writes carelessly confesses thereby at the very outset that he does
> not attach much importance to his own thoughts.
-- Arthur Schopenhauer

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2013-11-04 22:51:27 Re: table lock when where clause uses unique constraing instead of primary key.
Previous Message Kevin Grittner 2013-11-04 22:14:00 Re: Suitable Index for my Table