Re: Suitable Index for my Table

Поиск
Список
Период
Сортировка
От Kevin Grittner
Тема Re: Suitable Index for my Table
Дата
Msg-id 1383590443.49877.YahooMailNeo@web162906.mail.bf1.yahoo.com
обсуждение исходный текст
Ответ на Suitable Index for my Table  ("Janek Sendrowski" <janek12@web.de>)
Список pgsql-general
Janek Sendrowski <janek12@web.de> wrote:

> I've got a table with many Values of the Type REAL.
> These are my metric distances or my pivots to my sentences.
> The table looks like this:
>
> ID INTEGER, distance1 REAL, distance2 REAL, distance3 REAL,
> distance4 REAL, ..., distance24 REAL

It should always raise a big red flag when you see column names
with numeric suffixes like that.  Usually these represent data
which should be normalized out to another table, or possibly
represented by a single column which is an array, hstore, or json
type.

> The range of the Value is in between 0 and 1. So it looks like
> this 0.196 or 0.891
>
> That my query
>
> WHERE value BETWEEN (distance1 - radius) AND (distance1 + radius)
> WHERE value BETWEEN (distance2 - radius) AND (distance2 + radius)
> WHERE value BETWEEN (distance3 - radius) AND (distance3 + radius)
> WHERE value BETWEEN (distance4 - radius) AND (distance4 + radius)
> ...

Are those the WHERE clauses of four different queries, or did you
mean for those to be four criteria on a single query?  It would be
better to show an actual, working query and table layout, so people
have a more clear idea of the problem they are being asked to help
solve.

> Now I'm searching for a suitable index.

A btree index on each distance column, maybe?

--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


В списке pgsql-general по дате отправления:

Предыдущее
От: Jeff Amiel
Дата:
Сообщение: Re: table lock when where clause uses unique constraing instead of primary key.
Следующее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: Suitable Index for my Table