Subject | Problem with PLAN and ORDER BY on 2 columns |
---|---|
Author | Sototh |
Post date | 2002-07-31T12:50:11Z |
Hello!
1. I have a table, looks like this:
CREATE TABLE KLIENT (
ID INTEGER NOT NULL,
NAZWA_1 VARCHAR(65) NOT NULL,
NAZWA_2 VARCHAR(65)
)
2. I've created some indices for this table columns:
CREATE INDEX NAZWA_1 ON KLIENT (NAZWA_1);
CREATE DESCENDING INDEX NAZWA_1_DESC ON KLIENT (NAZWA_1);
CREATE INDEX NAZWA_2 ON KLIENT (NAZWA_2);
CREATE DESCENDING INDEX NAZWA_2_DESC ON KLIENT (NAZWA_2);
3. Now I want to execute this statement:
SELECT * FROM klient
PLAN SORT (klient INDEX (nazwa_1, nazwa_2))
ORDER BY nazwa_1, nazwa_2
4. An error occurs:
"index NAZWA_1 cannot be used in the specified plan."
Why does it happen? What is wrong with this? I tried to execute the same
statement without PLAN specified, but then no indices are used and statement
proceedes much slower than it should be. When I use ORDER BY on a single column,
everything works fine - with use of proper index.
Thank you for any help!
greetz
Sototh
1. I have a table, looks like this:
CREATE TABLE KLIENT (
ID INTEGER NOT NULL,
NAZWA_1 VARCHAR(65) NOT NULL,
NAZWA_2 VARCHAR(65)
)
2. I've created some indices for this table columns:
CREATE INDEX NAZWA_1 ON KLIENT (NAZWA_1);
CREATE DESCENDING INDEX NAZWA_1_DESC ON KLIENT (NAZWA_1);
CREATE INDEX NAZWA_2 ON KLIENT (NAZWA_2);
CREATE DESCENDING INDEX NAZWA_2_DESC ON KLIENT (NAZWA_2);
3. Now I want to execute this statement:
SELECT * FROM klient
PLAN SORT (klient INDEX (nazwa_1, nazwa_2))
ORDER BY nazwa_1, nazwa_2
4. An error occurs:
"index NAZWA_1 cannot be used in the specified plan."
Why does it happen? What is wrong with this? I tried to execute the same
statement without PLAN specified, but then no indices are used and statement
proceedes much slower than it should be. When I use ORDER BY on a single column,
everything works fine - with use of proper index.
Thank you for any help!
greetz
Sototh