Jump to content

Working with large database tables


Asheeown

Recommended Posts

I think this is important, I did a show index query on the table.  It brought my Index up however UTCTime is first in the sequence.

[quote]
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
rated_cdrs 0 PRIMARY 1 ID A 2888305 NULL NULL   BTREE
rated_cdrs 1 IdTime 1 UTCTime A 2888305 NULL NULL YES BTREE
rated_cdrs 1 IdTime 2 Originating_TG A 2888305 NULL NULL YES BTREE


[/quote]
effigy's off to a good start... BETWEEN is definitely more logic, and easier to read, and gives the parser/optimizer a hint that the same field needs to be examined for both inequalities.  However, if you're going to be sorting often, you should have a covering index on ( UTCTime, Originating_TG ), which will remove the filesort, and speed up your query.  You won't be able to ever use the lone index on the latter because you're using IN().

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.