Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Index

Status
Not open for further replies.

Renier2

Programmer
May 16, 2006
1
ZA
I have the following query, but it runs a bit slow as the table consist of about 30 000 records, i want to know on which columns i must create what type of index to maximize the query?

select r_curcode, r_curdesc, to_char(r_sellrate,'999990.0000') as sellrate, to_char(r_buyrate,'999990.0000') as buyrate, to_char(r_buyairmail,'999990.0000') as buyairmail, to_char(r_buysurfmail,'999990.0000') as buysurfmail from someTable order by datesubmitted, timesubmitted desc limit 3
 
Well I'd be inclined to put a Compound Index on DateSubmitted and TimeSubmitted.

CREATE INDEX Index_Name ON Table_Name (DateSubmitted, TimeSubmitted)

Then run your query through EXPLAIN and see the results (I think you may be surprised at them), if its not what you'd expect then create two indicies one for each column.

HTH


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top