srm
srm

Reputation: 665

ActiveRecord alternatives to limit due to performance issues

I am experiencing performance issues when using limit on thousands of records.

Are there any alternatives too limit that active record provides or workarounds?

My query is Spot.where(<where_conditions>).limit(20)

Some solutions I have thought about;

Upvotes: 0

Views: 285

Answers (1)

B&#249;i Nhật Duy
B&#249;i Nhật Duy

Reputation: 322

Consider your where_condition:

  • All columns in where_condition indexed? Did them indexed in right order as in where_condition?

  • If you did not index all columns in where_condition. You can use deferred_join to improve performance

Upvotes: 1

Related Questions