Hi
i've got a table
Id,Name,Status,DateAdded,Rate
So i'd like to select 5 newest records with status = 1
so i need here index on (Status,DateAdded)
later i query for 100 top rated
so i need here index on (Status,Rate)
And now technical questions
Which is better:
or
gry online
i've got a table
Id,Name,Status,DateAdded,Rate
So i'd like to select 5 newest records with status = 1
Code:
SELECT * FROM Table WHERE Status = 1 ORDER BY DateAdded DESC LIMIT 5
so i need here index on (Status,DateAdded)
later i query for 100 top rated
Code:
SELECT * FROM Table WHERE Status = 1 ORDER BY Rate DESC LIMIT 100
so i need here index on (Status,Rate)
And now technical questions
Which is better:
Code:
CREATE INDEX IX_A ON Table (Status,DateAdded);
CREATE INDEX IX_B ON Table (Status,Rate);
Code:
CREATE INDEX IX_A ON Table (Status);
CREATE INDEX IX_B ON Table (Rate);
CREATE INDEX IX_C ON Table (DateAdded);
gry online