Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

'unread comment count' was being calculate as:

unread_comment_count

...

= Comment.collection.find(:comment_thread_id

...

=>

...

t._id,

...

:author_id

...

=>

...

{"$ne"

...

=>

...

user.id},

...

:updated_at

...

=>

...

{"$gte"

...

=>

...

read_dates[thread_key]}).count

and

...

had

...

a

...

compound

...

index

...

against

...

it
index({_type: 1,

...

comment_thread_id: 1,

...

author_id: 1,

...

updated_at: 1})
 

With new implementation:

unread_comment_count

...

= Comment.collection.find(:comment_thread_id

...

=>

...

t._id, :author_id

...

=>

...

{"$ne"

...

=>

...

user.id}, :created_at

...

=>

...

{"$gte"

...

=>

...

read_dates[thread_key]}).count

So,

...

we

...

removed

...

index
index({_type: 1,

...

comment_thread_id: 1,

...

author_id: 1,

...

updated_at: 1})

and

...

added

...

a

...

new

...

one

index({comment_thread_id: 1,

...

author_id: 1,

...

created_at: 1})

 

The results of load tests below show difference between the old and new implementation.

...