Jump to content

[SOLVED] Covering index


jaymc

Recommended Posts

I have read a bit about using covering indexes

 

In this example select b from tbl where a=5

 

Having a covering index over a,b would mean only one read from the index, rather than a index read to get the row pointer and then table to get the data

 

Simple enough, but lets say I wanted to have

 

select b,c,d,e,f from tbl where a=5

 

Does that mean, to effectively use a covering index in that situation I would need a index covering a,b,c,d,e,f

 

If so, again simple enough but what if I have various queries that pull out different fields, for example

 

select d,e,f from tbl where a=5

select b,e,f from tbl where a=5

selecte,f from tbl where a=5

 

Is that a covering index for each of them?

 

Any more info on how to use this effectively would be great

Link to comment
Share on other sites

So pretty much only useful if that table is queried with the same queries over and over..

It depends how the table is set up... if you always tend to pull a single column based on the value of a few others (e.g. "name" in a lookup table with two uids) then it can be quite helpful.  Otherwise, covering indexes are very useful for group by / order by operations, since it can often prevent a filesort.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.