On Mon, Nov 4, 2013 at 2:10 PM, Caio Casimiro <casimiro.listas@xxxxxxxxx> wrote:
You said that I would need B-Tree indexes on the fields that I want the planner to use index only scan, and I think I have them already on the tweet table:"tweet_ios_index" btree (id, user_id, creation_time)Shouldn't the tweet_ios_index be enough to make the scan over tweet_creation_time_index be a index only scan?
You can't efficiently scan an index when the first column in it is not constrained. You would have to define the index as (creation_time, user_id, id) instead to get it to use an IOS.
And, more important, would it be really faster?
Probably.
Cheers,
Jeff