GET 24/7 LIVE HELP NOW

Announcement

Announcement Module
Collapse
No announcement yet.

Optimizing a query

Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Optimizing a query

    Hi,

    Any idea to optimize the next query:

    SELECT
    COUNT(*) - SUM(success) AS failed,
    COUNT(*) AS total,
    SUM(success) / COUNT(*) * 100 AS percent,
    FROM_UNIXTIME(FLOOR(UNIX_TIMESTAMP(TIME) / 300) * 300) AS START
    FROM reports
    GROUP BY FLOOR(UNIX_TIMESTAMP(TIME) / 300) LIMIT 100;

    Thanks for the help.

  • #2
    You need to index it and rewrite it so that an index can be used for the GROUP BY. You should include SHOW CREATE TABLE reports\G

    Comment

    Working...
    X