Re: select single entry and its neighbours using direct-acess to index?

Поиск
Список
Период
Сортировка
От Pierre-Frédéric Caillaud
Тема Re: select single entry and its neighbours using direct-acess to index?
Дата
Msg-id opsikzyrypcq72hf@musicbox
обсуждение исходный текст
Ответ на select single entry and its neighbours using direct-acess to index?  (peter pilsl <pilsl@goldfisch.at>)
Ответы Re: select single entry and its neighbours using direct-acess
Список pgsql-general
> select id from mytable where id=45 order by name,name2;

    Why do you want to select id if you already know it ?
    Do you not want to specify a starting value for name and name2 ?

    I'll presume you want to select a row by its 'id' and then get the
previous and next ones in the name, name2 order. I'll guess the id is
UNIQUE so these two other rows won't have the same id.

    If I guessed right I have the solution, if I'm not please explain what
you wanna do more precisely ;)

>
> and then I'd like to select the two entries that would come before and
> after according to the order "name,name2";
> id is not ordered, but there is an index on  (name,name2) so the needed
> infomation about previous, next should be stored somewhere in this index.
>
> My current solution is to read all the data without the WHERE-clause and
> then fetch the needed ones, which is quite time-demanding.
>
> thnx,
> peter
>
>
>



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

Предыдущее
От: dom@happygiraffe.net (Dominic Mitchell)
Дата:
Сообщение: Re: When to encrypt
Следующее
От: peter pilsl
Дата:
Сообщение: Re: select single entry and its neighbours using direct-acess