GET 24/7 LIVE HELP NOW

Announcement

Announcement Module
Collapse
No announcement yet.

Optimizing simple order by query

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

  • Optimizing simple order by query

    Hello I am having problems in optimizing a simple order by clause.

    the query is:
    explain SELECT `Entity`.`title`, `Entity`.`description`, `Entity`.`user_id`, `Entity`.`thumb_url`, `Entity`.`entity_uid`, `Entity`.`num_fachaks`, `Entity`.`number_of_views` FROM `entities` AS `Entity` ORDER BY `Entity`.`created` DESC LIMIT 21 \G
    *************************** 1. row ***************************
    id: 1
    select_type: SIMPLE
    table: Entity
    type: ALL
    possible_keys: NULL
    key: NULL
    key_len: NULL
    ref: NULL
    rows: 11
    Extra: Using filesort

    I have index on the created filed by really dont understand that why mysql does not use it and prefers file sort.. the created field is a timestamp default current_timestamp.

    Please help ... i am new to mysql and badly stuck.

    Thanks.

  • #2
    Try FORCE INDEX.

    Comment

    Working...
    X