Subject First word after in alphabetical order
Author ericsibert1971
Hi,

I have a table with a lot of names in a colomn. Giving the beginning
of a word, I want to be able to go to the corresponding area in the
table and to have an overview of the area. More precisely, I'm
looking for FISHE. I want to retrieve the first record in
alphabetical after FISHE, inclunding FISHE itself if it exists. I
also want the ten next and ten previous records in alphabetical
order. Therefore, I tried :
- for the first and ten next :
SELECT FIRST 11
ID_NAME
FROM NAMES
WHERE NAME>='FISHE'
ORDER BY NAME;

-for the ten previous :
SELECT FIRST 10
ID_NAME
FROM NAMES
WHERE NAME<'FISHE'
ORDER BY NAME DESC;

But this is very slow. 1m45s each on my server (FB1.5.2 /Linux).

In opposite :
SELECT FIRST 11
ID_NAME
FROM NAMES
WHERE NAME LIKE 'FISHE%'
ORDER BY NAME;

only need 1s (but don't give the right result if less than 11 names
are starting with FISHE).

Any idea to solve my problem (the global one, not just improving my
requests)?

Eric