Crea un indice composito su postings (is_active, post_date) (in quest'ordine).
Verrà utilizzato sia per filtrare su is_active e ordinando per post_date .
MySQL dovrebbe mostrare REF metodo di accesso su questo indice in EXPLAIN EXTENDED .
Nota che hai un RANGE condizione di filtro su user_offtopic_count , ecco perché non puoi utilizzare un indice su questo campo sia nel filtraggio che nell'ordinamento per altro campo.
A seconda di quanto è selettivo il tuo user_offtopic_count (cioè quante righe soddisfano user_offtopic_count < 10 ), potrebbe essere più utile creare un indice su user_offtopic_count e lascia che i post_dates siano ordinati.
Per fare ciò, crea un indice composito su postings (is_active, user_offtopic_count) e assicurati che il RANGE viene utilizzato il metodo di accesso su questo indice.
Quale indice sarà più veloce dipende dalla distribuzione dei dati. Crea entrambi gli indici, FORCE loro e vedere quale è più veloce:
CREATE INDEX ix_active_offtopic ON postings (is_active, user_offtopic_count);
CREATE INDEX ix_active_date ON postings (is_active, post_date);
SELECT
`postings`.`id`,
UNIX_TIMESTAMP(postings.post_date) as post_date,
`postings`.`link`,
`postings`.`title`,
`postings`.`author`,
`postings`.`excerpt`,
`postings`.`long_excerpt`,
`feeds`.`title` AS feed_title,
`feeds`.`website` AS feed_website
FROM
`postings` FORCE INDEX (ix_active_offtopic)
JOIN
`feeds`
ON
`feeds`.`id` = `postings`.`feed_id`
WHERE
`feeds`.`type` = 1 AND
`postings`.`user_offtopic_count` < 10 AND
`postings`.`is_active` = 1
ORDER BY
`postings`.`post_date` desc
LIMIT
15
/* This should show RANGE access with few rows and keep the FILESORT */
SELECT
`postings`.`id`,
UNIX_TIMESTAMP(postings.post_date) as post_date,
`postings`.`link`,
`postings`.`title`,
`postings`.`author`,
`postings`.`excerpt`,
`postings`.`long_excerpt`,
`feeds`.`title` AS feed_title,
`feeds`.`website` AS feed_website
FROM
`postings` FORCE INDEX (ix_active_date)
JOIN
`feeds`
ON
`feeds`.`id` = `postings`.`feed_id`
WHERE
`feeds`.`type` = 1 AND
`postings`.`user_offtopic_count` < 10 AND
`postings`.`is_active` = 1
ORDER BY
`postings`.`post_date` desc
LIMIT
15
/* This should show REF access with lots of rows and no FILESORT */