Is there a way to optimize this request ?

Hi,
The above function returns the YEARS of the lines of a table. Each line contains a date. Data Sample :
3487     22/06/2003 17:19:53     2,288
3487     22/06/2003 17:20:54     8,277
3467     22/06/2003 17:21:32     40,1378
3487     22/06/2003 17:23:32     2,386
3467     22/06/2003 17:23:57     38,9814
The table contains 4 060 521 lines....
DECLARE
X VARCHAR2 (4000);
BEGIN
X := 'SELECT distinct(TO_CHAR(DATE1, ''YYYY'')) d, (TO_CHAR(DATE1, ''YYYY'')) r
FROM EVV_'||:p4_site ||' order by d';
RETURN X ;
END;Is there a way to reduce the time taken by the request ? kind of optimization ?
Thank you for you kind help.
Christian.

>
Salut,
First things first DB version/OS/Hardware - Disk/CPU.
The above function returns the YEARS of the lines of a table. Each line contains a date. Data Sample :
3487     22/06/2003 17:19:53     2,288
3487     22/06/2003 17:20:54     8,277
3467     22/06/2003 17:21:32     40,1378
3487     22/06/2003 17:23:32     2,386
3467     22/06/2003 17:23:57     38,9814
The table contains 4 060 521 lines....
DECLARE
X VARCHAR2 (4000);
BEGIN
X := 'SELECT distinct(TO_CHAR(DATE1, ''YYYY'')) d, (TO_CHAR(DATE1, ''YYYY'')) r
FROM EVV_'||:p4_site ||' order by d';
RETURN X ;
END;
Is there a way to reduce the time taken by the request ? kind of optimization ?Furthermore, we don't know the time taken, you haven't told us!
Put in a query plan for this if you want more information.
Use a functional index? Put an index on the TO_CHAR of the year for that
field of that table? BTW, this is just a guess.
Thank you for you kind help.De rien.
Paul...
Christian.--
When asking database related questions, please give other posters
some clues, like OS (with version), version of Oracle being used and DDL.
Other trivia such as CPU, RAM + Disk configuration might also be useful.
The exact text and/or number of error messages is useful (!= "it didn't work!"). Thanks.
Furthermore, as a courtesy to those who spend time analysing and attempting to help,
please do not top post and do try to trim your replies!

Similar Messages

Maybe you are looking for