Index tiny ints?

This is a discussion on Index tiny ints? within the MySQL Database forums, part of the Database Forums category; Hi, I have articles that I want to display by date, (so the latest articles are always shown first). So ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-15-2008
FFMG
 
Posts: n/a
Default Index tiny ints?


Hi,

I have articles that I want to display by date, (so the latest articles
are always shown first).

So I have an index on the time, (SELECT article FROM tablea ORDER BY
article_time DESC LIMIT 0,5).

Now I want to offer my editors 2 extra options
1- The item is not a frontpage news article
2- The article is marked as 'deleted'

So my select would become

SELECT article FROM tablea WHERE isdeleted=0 and isfrontpage=1 ORDER BY
article_time DESC LIMIT 0,5

isdeleted and isfrontpage will only be 0 or 1
there will be thousands of articles.

Should I create an index on 'tablea'

INDEX idx_article ( article_time, isdelted, isfrontpage)

or should I create a key for each one of them

KEY article_time ( article_time)
KEY article_deleted ( isdeleted)
KEY article_frontpage ( isfrontpage)

What would be the best way to optimize that select?

Thanks

FFMG


--

'webmaster forum' (http://www.httppoint.com) | 'Free Blogs'
(http://www.journalhome.com/) | 'webmaster Directory'
(http://www.webhostshunter.com/)
'Recreation Vehicle insurance'
(http://www.insurance-owl.com/other/car_rec.php) | 'Free URL
redirection service' (http://urlkick.com/)
------------------------------------------------------------------------
FFMG's Profile: http://www.httppoint.com/member.php?userid=580
View this thread: http://www.httppoint.com/showthread.php?t=24235

Message Posted via the webmaster forum http://www.httppoint.com, (Ad revenue sharing).

Reply With Quote
  #2 (permalink)  
Old 01-15-2008
Captain Paralytic
 
Posts: n/a
Default Re: Index tiny ints?

On 15 Jan, 06:17, FFMG <FFMG.337...@no-mx.httppoint.com> wrote:
> Hi,
>
> I have articles that I want to display by date, (so the latest articles
> are always shown first).
>
> So I have an index on the time, (SELECT article FROM tablea ORDER BY
> article_time DESC LIMIT 0,5).
>
> Now I want to offer my editors 2 extra options
> 1- The item is not a frontpage news article
> 2- The article is marked as 'deleted'
>
> So my select would become
>
> SELECT article FROM tablea WHERE isdeleted=0 and isfrontpage=1 ORDER BY
> article_time DESC LIMIT 0,5
>
> isdeleted and isfrontpage will only be 0 or 1
> there will be thousands of articles.
>
> Should I create an index on 'tablea'
>
> INDEX idx_article ( article_time, isdelted, isfrontpage)
>
> or should I create a key for each one of them
>
> KEY article_time ( article_time)
> KEY article_deleted ( isdeleted)
> KEY article_frontpage ( isfrontpage)
>
> What would be the best way to optimize that select?
>
> Thanks
>
> FFMG
>
> --
>
> 'webmaster forum' (http://www.httppoint.com) | 'Free Blogs'
> (http://www.journalhome.com/) | 'webmaster Directory'
> (http://www.webhostshunter.com/)
> 'Recreation Vehicle insurance'
> (http://www.insurance-owl.com/other/car_rec.php) | 'Free URL
> redirection service' (http://urlkick.com/)
> ------------------------------------------------------------------------
> FFMG's Profile:http://www.httppoint.com/member.php?userid=580
> View this thread:http://www.httppoint.com/showthread.php?t=24235
>
> Message Posted via the webmaster forumhttp://www.httppoint.com, (Ad revenue sharing).


IMHO, the only indexes that the optimiser would have a hope of using
in this case would be a composite one of
isdeleted + isfrontpage + article_time
or
isfrontpage + isdeleted + article_time
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 04:13 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0