Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3950940
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:40:15+00:00 2026-05-20T01:40:15+00:00

I am using rails and have the following scenario: Users have_many lists and each

  • 0

I am using rails and have the following scenario: Users have_many lists and each list contains a number of words with each word having its own definition. The list show view shows all the words paginated by multiples of 30. I am concerned b/c a list can grow to have over 4,000 words and this seems like it would be way to expensive for the database to paginate if the list needs to be ordered alphabetically. I’m wondering what the fastest way to do this is. Maybe adding an index on the word?

I have considered saving a string in the list that contains all the words in the list separated by a space. I could then do a split(” “) on this string and use pagination on this array, but then I need to use regular expressions to add and delete words from this list along with a word object save.

I have also considered some sort of key-value store like tokyo cabinet. It looks like a B-Tree index could work.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T01:40:15+00:00Added an answer on May 20, 2026 at 1:40 am

    Index it! This is by far the best option, and like Mark Thomas said, it’ll give you any 30 consecutive words just as quickly as it’ll give you the first 30. Just throw in an :order and a :limit and you’re good to go – or, better yet, let a plug-in like will_paginate do it all for you.

    The word string is a pretty messy approach – you’d have to rebuild the string every time you added or removed words, and work lookups would have to use slow comparison functions like LIKE or REGEX.

    Tokyo (now Kyoto) Cabinet might not be versatile enough for what you need – it claims to be a key -> value store, and you might need multiple keys -> value, which I’m not sure it supports. Besides, why add another DB when you’ve already got one?

    tl;dr INDEX!

    Hope this helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Rails 3.0.3. I have the following route in routes.rb: match user/create_new_password/:reset_password_key =>users#create_new_password, :via=>[:get,
I am using Ruby on Rails 3.2.2. I have the following scenario: # hash_params.class
I am using Rails 3.2. I have following models: Blog Comment User class Blog
I'm using jQuery with rails and have the following piece of code $('#related').html(<%= render
Using Rails 3.2. I have an individual Shop post, and each shop has reviews.
Using Rails 3.2.0.rc2 and ruby 1.9.3p0 In app/views/requests/_form.html.erb I have the following code for
I am using Ruby on Rails v3.2.2. I have following associations with an alias_method
Using Rails 3. I have the following: # shop.rb SHOP_TYPES = %w(cafe restaurant station)
I'm using: Rails 3.0.9 Activerecord-sqlserver-adapter 3.0.15 TinyTds MSSQL 2005 I have following table: CREATE
I am using MySQL and I am having the following scenario: Table nodes: node_id,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.